チェックボックスとテキストボックスが連続したデータグリッドがあります。値が変更されたときにテキストボックスが変更されてEnterキーが押された場合、値が変更されたかどうかに基づいてチェックボックスをオンにする必要があります。どうすればこれができますか?私はファイルの後ろにコードを持っていません。
1 に答える
0
<DataGrid...ItemsSource={Binding ViewModel.YourRowItems
...some column
<TextBox Text="{Binding SomeText}"...
....some column
<CheckBox IsChecked="{Binding IsChecked="{Binding IsSomeProp}"..
ViewModelで、SomeTextプロパティが変更された場合、IsSomePropを反転/更新します。これにより、バインディングを通じてIsCheckedが更新されます。
public string SomeText
{
get {return _someText;}
set
{
if (_someText != value ..
{
_someText = value;
if(value != _originalSomeText)
IsSomeProp = true;//this of course will raise prop changed for IsSomeProp
RaisePropertyChanged( ()=> SomeText);
}
}
...とにかくそれが要点です
于 2012-05-03T18:47:32.310 に答える