I have a number of radio buttons which are used to change an option, by being bound to a command with a command parameter, like this:
<RadioButton
Content="Option1"
Command="{Binding ChangeOption}
CommandParameter="Option1" />
The code to change options is the view model is quite simple:
public property SelectedOption { get; set; }
public void ChangeOption(string option)
{
SelectedOption = option;
}
This is simplified a bit, but it pretty much describes the concept. What I am missing is, to decide whether or not a radio button is checked, based on the SelectedOption
property. I want to compare this property to the Content
(or CommandParameter
) of the RadioButton
. This should be done in a trigger, which can then alter the IsSelected
property.
The problem is, that I cannot figure out, how to access either the Content
or CommandParamater
in the Data Trigger. I am stuck at something like this:
<Style.Triggers>
<DataTrigger Binding={Binding SelectedOption} Value="?????">
<Setter Property="IsChecked" Value="True" />
</DataTrigger>
</Style.Triggers>
What do I put in the Value
parameter of the Data Trigger, to compare it to the selected option?