WPF ListViewItem Commands with MVVM pattern

If you're interested to see how to attach commands to listview items for use with an implementation of the MVVM pattern, have a look at this.

 

[code:c#]

<Style x:Key="Local_OpenEntityStyle"
           TargetType="{x:Type ListViewItem}">
        <Setter Property="acb:CommandBehavior.Event"
                        Value="MouseDoubleClick" />
        <Setter Property="acb:CommandBehavior.Command"
                        Value="{Binding ElementName=uiEntityListDisplay, Path=DataContext.OpenEntityCommand}" />
        <Setter Property="acb:CommandBehavior.CommandParameter"
                        Value="{Binding}" />
</Style>

[/code]

 

Here the command to be fired on the MouseDoubleClick event is set, the CommandParameter, will be the data object that we click on.

Comments are closed