I have a comboBox which has the following items: a1, a2, a3, a4 and I have two RadioButtons r1 and r2. This is what I want to accomplish: if the user selects item a2 from the combobox the IsChecked property of r1 should be set to true. If the user selects either item a3 or a4 from the combobox the IsChecked propertyr of r2 should be set to true. I would like to accomplish this declaratively; i.e. without using a Converter. Here is my Code and thanks in advance:
<Window x:Class="BMSystem.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<Window.Resources>
<Style x:Key="myRadioActivator1">
<Style.Triggers>
<DataTrigger Binding="{Binding Path=Content, ElementName=comboBox1}" Value="R2">
<Setter Property="RadioButton.IsChecked" Value="True"/>
</DataTrigger>
</Style.Triggers>
</Style>
<Style x:Key="myRadioActivator2">
<Style.Triggers>
<DataTrigger Binding="{Binding Path=Content, ElementName=comboBox1}" Value="R3">
<Setter Property="RadioButton.IsChecked" Value="True"/>
</DataTrigger>
<DataTrigger Binding="{Binding Path=Content, ElementName=comboBox1}" Value="R4">
<Setter Property="RadioButton.IsChecked" Value="True"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Window.Resources>
<Grid>
<ComboBox Height="23" HorizontalAlignment="Left" Margin="10,10,0,0" Name="comboBox1" VerticalAlignment="Top" Width="120" SelectionChanged="comboBox1_SelectionChanged">
<ComboBoxItem>R1</ComboBoxItem>
<ComboBoxItem>R2</ComboBoxItem>
<ComboBoxItem>R3</ComboBoxItem>
<ComboBoxItem>R4</ComboBoxItem>
</ComboBox>
<RadioButton Height="16" HorizontalAlignment="Left" Margin="10,43,0,0" Name="r1" VerticalAlignment="Top" Width="120" Style="{StaticResource myRadioActivator1}">
</RadioButton>
<RadioButton Height="16" HorizontalAlignment="Left" Margin="10,69,0,0" Name="r2" VerticalAlignment="Top" Width="120" Style="{StaticResource myRadioActivator2}">
</RadioButton>
</Grid>
</Window>