I have 4 ListViews in my Window, every ListView has a CheckBox column Like this:
Now I want to implement 1 Command, which I can bind to the CheckBox in the header of each ListView I have. So if the CheckBox in the header is clicked it will select all items in that ListView and if clicked again, it will unselect them all again.
I know it would be easy to do that via a click event in code behind, but i don't think that is MVVM conform, is it?
But I also don't want to have 4 different "IsSelected" Properties in my ViewModel which I could then bind to the style of the listview like someone suggested in this post: Select All items in ListView with MVVM
Is there any other way? Is it maybe possible to send the ListView Control as command parameter?
I tried that:
<ListView x:Name="UserDemandListView" Grid.Column="2" Grid.Row="2" MinWidth="200" ItemsSource="{Binding DemandLicenses}" Grid.RowSpan="2">
<ListView.View>
<GridView>
<!--<SnippetGridViewColumnCheckBox>-->
<GridViewColumn CellTemplate="{StaticResource FirstCell}" Width="25">
<CheckBox x:Name="CheckAll3" Content="" Command="{Binding SelectAllCommand}" CommandParameter="{Binding ElementName=UserDemandListView}" Margin="4,0,0,0"/>
</GridViewColumn>
<!--</SnippetGridViewColumnCheckBox>-->
But the Parameter in my command is always null. My WPF skills are a bit rusty I guess ...