Validation.Error
TextBox の添付イベントで使用します。
にバインドしたいEventToCommand
。
通常は機能しません:
<TextBox Height="20" Width="150" Text="{Binding MyProperty,NotifyOnValidationError=True,ValidatesOnDataErrors=True}" ><!--Validation.Error="TextBox_Error"-->
<i:Interaction.Triggers>
<i:EventTrigger EventName="Validation.Error">
<mvvm:EventToCommand Command="{Binding MyCmd}" PassEventArgsToCommand="True" ></mvvm:EventToCommand>
</i:EventTrigger>
</i:Interaction.Triggers>
</TextBox>
それで、私はそれを行う方法を見つけました、あなたは以下のリンクでそれを見ることができます:
しかし、私はエラーが発生します:
RoutedEventConverter cannot convert from System.String.
誰でも助けることができますか?
編集 :
私のコマンドViewModel
public MyViewModel()
{
MyCmd = new RelayCommand<RoutedEventArgs>(Valid);
}
public RelayCommand<RoutedEventArgs> MyCmd { get; set; }
private void Valid(RoutedEventArgs args)
{
//Do something
}