私は次のXAMLを持っています-
<TextBox Text="{Binding Path=NumberOfItems, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}" />
<Button Command="{Binding Path=StartCommand}">Start</Button>
ViewModelで-
public string this[string columnName]
{
get
{
string result = null;
switch (columnName)
{
case "NumberOfItems":
if (this.NumberOfItems <= 0)
{
result = "Items required";
}
break;
}
return result;
}
}
TextBoxが値を変更するたびに、トリガーはそれに応じて機能します。しかし、次の場合、それは機能していません-
テキストボックスの全文を選択した後、ユーザーがキーボードの削除ボタンを押したとき。
ユーザーがTextBoxにある最後の文字を削除したとき。
ただし、ValidatesOnDataErrorは機能しています。
TextBoxが空になったときにどうすれば機能させることができますか?
ユーザーが無効なデータを入力すると、TextBoxスタイルが変更されます。スタートボタンをクリックしてこれを知らせたい。
TextBoxに無効なデータがあることを[スタート]ボタンに知らせるにはどうすればよいですか?