Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I like to use <a href="http://blogs.msdn.com/johngossman/archive/2008/05/07/the-attached-behavior-pattern.aspx" rel="noreferrer">Attached Command Behaviors</a> and Commands. <a href="http://marlongrech.wordpress.com/2008/12/13/attachedcommandbehavior-v2-aka-acb/" rel="noreferrer">Marlon Grech</a> has a very good implementation of the Attached Command Behaviors. Using these, we could then assign a style to the ListView's <a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.itemscontrol.itemcontainerstyle.aspx" rel="noreferrer">ItemContainerStyle</a> property that will set the command for each ListViewItem.</p> <p>Here we set the command to be fired on the MouseDoubleClick event, and the CommandParameter, will be the data object that we click on. Here I'm traveling up the visual tree to get the command that I'm using, but you could just as easily create application wide commands.</p> <pre><code>&lt;Style x:Key="Local_OpenEntityStyle" TargetType="{x:Type ListViewItem}"&gt; &lt;Setter Property="acb:CommandBehavior.Event" Value="MouseDoubleClick" /&gt; &lt;Setter Property="acb:CommandBehavior.Command" Value="{Binding ElementName=uiEntityListDisplay, Path=DataContext.OpenEntityCommand}" /&gt; &lt;Setter Property="acb:CommandBehavior.CommandParameter" Value="{Binding}" /&gt; &lt;/Style&gt; </code></pre> <p>For the commands, you can either implement an <a href="http://msdn.microsoft.com/en-us/library/ms752308.aspx" rel="noreferrer">ICommand</a> directly, or use some of the helpers like those that come in the <a href="http://www.codeplex.com/wpf" rel="noreferrer">MVVM Toolkit</a>.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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