I have a checkbox databound to a bool property in my view model called "ViewType". If "ViewType" is true then the checkbox is checked, otherwise it's not.
The thing is, the checkbox needs to be checked on and off from the view model rather than mouse click to fire off the command.
The said checkbox:
<CheckBox x:Name="ViewTypeCheckbox" IsChecked="{Binding ViewType, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Command="NavigationCommands.GoToPage" CommandParameter="/views/membership.xaml"/>
Unfortunately the command only fires by mouse click. I'm not entirely sure how to make this work using style triggers or data triggers. My most recent try being:
<CheckBox x:Name="ViewTypeCHeckbox">
<DataTrigger Binding="{Binding ElementName=ViewTypeCHeckbox, Path=IsChecked}" Value="True">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Button.Click">
<i:InvokeCommandAction Command="NavigationCommands.GoToPage" CommandParameter="Views/membership.xaml" />
</i:EventTrigger>
</i:Interaction.Triggers>
</DataTrigger>
</CheckBox>
But this doesn't work either... Is there any alteration I could make that could trigger the command?
Aucun commentaire:
Enregistrer un commentaire