I've got a checkbox and a button in my WPF MVVM app. If the checkbox is checked I want a tooltip on the button that says "x" and if it's unchecked the tooltip should say "y".
Anyone know the best way to do this? I think it could be done with a separate property in my view model, but maybe there's an easier way to do this in just the xaml?
Thanks in advance.
You could use a Style with a DataTrigger that binds to the IsChecked property of the CheckBox:
<CheckBox x:Name="chk" Content="CheckBox" />
<Button Content="Button">
<Button.Style>
<Style TargetType="Button">
<Setter Property="ToolTip" Value="y" />
<Style.Triggers>
<DataTrigger Binding="{Binding IsChecked, ElementName=chk}" Value="True">
<Setter Property="ToolTip" Value="x" />
</DataTrigger>
</Style.Triggers>
</Style>
</Button.Style>
</Button>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With