Color animate based on Radio Button Click event : RadioButton « Windows Presentation Foundation « C# / CSharp Tutorial






<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      Background="{x:Static SystemColors.WindowBrush}"
      Name="page">

    <Page.Resources>
        <Style TargetType="{x:Type RadioButton}">
            <Setter Property="Margin" Value="6" />
        </Style>
    </Page.Resources>

    <StackPanel HorizontalAlignment="Center"
                VerticalAlignment="Center"
                Background="{DynamicResource 
                                {x:Static SystemColors.ControlBrushKey}}">

        <RadioButton Content="Red">
            <RadioButton.Triggers>
                <EventTrigger RoutedEvent="RadioButton.Checked">
                    <BeginStoryboard>
                        <Storyboard>
                            <ColorAnimation 
                                Storyboard.TargetName="page"
                                Storyboard.TargetProperty="Background.Color"
                                To="Red" Duration="0:0:1" />
                        </Storyboard>
                    </BeginStoryboard>
                </EventTrigger>
            </RadioButton.Triggers>
        </RadioButton>

    </StackPanel>
</Page>
WPF Color Animate Based On Radio Button Click Event








24.21.RadioButton
24.21.1.Checked RadioButtonChecked RadioButton
24.21.2.Use StackPanel to Hold RadioButtonsUse StackPanel to Hold RadioButtons
24.21.3.Circled Radio ButtonsCircled Radio Buttons
24.21.4.Color animate based on Radio Button Click eventColor animate based on Radio Button Click event
24.21.5.Radio Button GroupsRadio Button Groups
24.21.6.Set RadioButton to check stateSet RadioButton to check state
24.21.7.Image RadioButtonImage RadioButton
24.21.8.Add checked event listener to RadioButton
24.21.9.Assign value to RadioButton tag