So I got a view which one got a listView. This ListView got an ItemSource "Persons" and this list view I got some some CheckBox.
When a CheckBox is checked I want to execute a command "CanStartRaceCheckCommand" from my ViewModel "RaceSimulatorViewModel".
But that doesn't work because the program try to get a command from my class Person.
So there are some errors of bindings.
Can you please help me?
I have tried this solution : WPF MVVM: EventTrigger is not working inside CheckBox
There is the Xaml :
<ListView ItemsSource="{Binding Persons}" Grid.Row="1" Margin="40,100,367,46" Grid.RowSpan="3" Grid.ColumnSpan="2" >
<ListView.View>
<GridView>
<GridViewColumn Header="Full Name" DisplayMemberBinding="{Binding Path=Name}"/>
<GridViewColumn Header="Participe to race" >
<GridViewColumn.CellTemplate>
<DataTemplate>
<!--<CheckBox IsChecked="{Binding Path=IsParticipateToRace}" Command="{Binding CanStartRaceCheckCommand, RelativeSource={RelativeSource AncestorType={x:Type vm:RaceSimulatorViewModel}, AncestorLevel=1}}"></CheckBox>-->
<!--<CheckBox Command="{Binding CanStartRaceCheckCommand}" CommandParameter="{Binding IsChecked, RelativeSource={RelativeSource Self}}" />-->
<CheckBox IsChecked="{Binding Path=IsParticipateToRace}"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
and there is my output:
System.Windows.Data Error: 40 : BindingExpression path error: 'CanStartRAceCheckCommand' property not found on 'object' ''Person' (HashCode=43304686)'. BindingExpression:Path=CanStartRAceCheckCommand; DataItem='Person' (HashCode=43304686); target element is 'CheckBox' (Name=''); target property is 'Command' (type 'ICommand')