Follow these simple steps to create a data trigger that will act to change the Background and Content property of a Label, based on the radio button selection:
-
From the Solution Explorer, open the MainWindow.xaml file.
-
Let's divide the Grid panel into two columns:
<Grid.ColumnDefinitions> <ColumnDefinition/> <ColumnDefinition/> </Grid.ColumnDefinitions>
-
Now insert a Label of 150 x 100 dimension at column 0 (zero) and set its Foreground property to White:
<Label Width="150" Height="100" Grid.Column="0" Foreground="White" FontSize="20" BorderBrush="Gray" BorderThickness="1"/>
-
Insert a vertical StackPanel at Column 1 and add three radio buttons inside it. Make sure you set their names and the GroupName. The x:Name property is used to define the name of the controls and the GroupName="colors"...