I have a WPF app with the follow XAML
<CheckBox IsChecked="{Binding IsTime}" />
<TextBlock Text="Time" />
What I'd like is if the user clicks the textbox, it will toggle the CheckBox. In the same way we can use label
and a checkbox
in MVC.NET (well, HTML)
I could do this with events in the code behind but I'm using MVVM and as such, don't want to use those events.
The difference between my question and Change a Label's behavior to support toggling by click in WPF is that I'm already binding my CheckBox to something...
I hope this effort provides a clearer idea on what I'm trying to do
<CheckBox IsChecked="{Binding IsTime}" x:Name="Checky" />
<TextBlock Text="Time">
<TextBlock.Style>
<Style>
<Style.Triggers>
<Trigger Property="TextBlock.MouseDown" Value="True">
<Setter TargetName="Checky" Property="IsChecked" Value=Not IsTime> //WHAT TO DO HERE
</Setter>
</Trigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>