Note that there are some explanatory texts on larger screens.

plurals
  1. POEventToCommand with attached event
    text
    copied!<p>I use on attached event <code>Validation.Error</code> of the TextBox.</p> <p><strong><a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.validation.error%28v=vs.100%29.aspx" rel="nofollow noreferrer">Validation.Error</a></strong></p> <p>I want to bind it to <code>EventToCommand</code>.</p> <p>Normally it does not work:</p> <pre><code> &lt;TextBox Height="20" Width="150" Text="{Binding MyProperty,NotifyOnValidationError=True,ValidatesOnDataErrors=True}" &gt;&lt;!--Validation.Error="TextBox_Error"--&gt; &lt;i:Interaction.Triggers&gt; &lt;i:EventTrigger EventName="Validation.Error"&gt; &lt;mvvm:EventToCommand Command="{Binding MyCmd}" PassEventArgsToCommand="True" &gt;&lt;/mvvm:EventToCommand&gt; &lt;/i:EventTrigger&gt; &lt;/i:Interaction.Triggers&gt; &lt;/TextBox&gt; </code></pre> <p>So I found a way to do it, you can see it at the link below:</p> <p><strong><a href="http://sergecalderara.wordpress.com/2012/08/23/how-to-attached-an-mvvm-eventtocommand-to-an-attached-event/" rel="nofollow noreferrer">Attached an mvvm event to command to an attached event</a></strong></p> <p>But I get an error:</p> <pre><code>RoutedEventConverter cannot convert from System.String. </code></pre> <p><img src="https://i.stack.imgur.com/741Wx.png" alt="enter image description here"></p> <p>Can anyone help?</p> <p><strong>EDIT :</strong></p> <p>My command in the <code>ViewModel</code></p> <pre><code> public MyViewModel() { MyCmd = new RelayCommand&lt;RoutedEventArgs&gt;(Valid); } public RelayCommand&lt;RoutedEventArgs&gt; MyCmd { get; set; } private void Valid(RoutedEventArgs args) { //Do something } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload