私は自分のプロジェクトの 1 つに WPF MVVM を使用しています。オブジェクトのリストにバインドするデータグリッドがあります。
<DataGrid ItemsSource="{Binding Path=ListOfValues}" Margin="5,38"
私のビュー モデル クラスには、ListOfValues のプロパティがあります。
public ObservableCollection<ClassA> ListOfValues
{
get { return listOfValues; }
set
{
listOfValues= value;
RaisePropertyChangedEvent("ListOfValues");
}
}
私の ClassA には、3 つのプロパティがあります。
public string Name { get; set; }
public long No { get; set; }
public decimal Amount { get; set; }
グリッドでは、ユーザーは金額フィールドの値のみを入力できます。ユーザーがそのフィールドに有効な小数値を入力したかどうかを検証したいと思います。
例外をキャッチできる場所を教えてください。私は窓の近くでそれを処理しようとします。ただし、ユーザーが無効な値を入力すると、ビューのデータ コンテキストに保存されません。また、ClassAのセッターで値のセッターにヒットしないことを検証しようとしました。