Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The solution is to use Commands.</p> <p>Since its a UserControl you may manipulate it to implement ICommandSource interface.</p> <p>Then your UserControl will be able to bind a Command to ViewModel.</p> <p>Once the event is being fired you simply call the command which will invoke Execute() method from the ViewModel.</p> <p>For commanding in WPF I suggest you to read following link:</p> <p><a href="http://msdn.microsoft.com/en-us/library/ms752308(v=vs.110).aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/ms752308(v=vs.110).aspx</a></p> <p>In your ViewModel you will have to offer a property of type ICommand.</p> <p><strong>EDIT</strong> Since you cannot manipulate your UserControl you will have to attach a command on it in XAML.</p> <p>Interactivity is also an alternative to solve your issue. Take a look at this code:</p> <pre><code> xmlns:I="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" &lt;ListBox ...&gt; &lt;i:Interaction.Triggers&gt; &lt;i:EventTrigger EventName="SelectionChanged"&gt; &lt;i:InvokeCommandAction Command="{Binding SelectedItemChangedCommand}"/&gt; &lt;/i:EventTrigger&gt; &lt;/i:Interaction.Triggers&gt; &lt;/ListBox&gt; </code></pre> <p>Interactivity is a third party dll from Microsoft Blend.</p> <p>If you have nuget in visual studio you will be able to find that dll. If not here is the link: <a href="http://www.nuget.org/packages/System.Windows.Interactivity.WPF/" rel="nofollow">http://www.nuget.org/packages/System.Windows.Interactivity.WPF/</a></p>
 

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