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






Color animate based on Radio Button Click event

Color animate based on Radio Button Click event
      
<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>

   
    
    
    
    
    
  








Related examples in the same category

1.Checked RadioButtonChecked RadioButton
2.Use StackPanel to Hold RadioButtonsUse StackPanel to Hold RadioButtons
3.Circled Radio ButtonsCircled Radio Buttons
4.Radio Button GroupsRadio Button Groups
5.Set RadioButton to check stateSet RadioButton to check state
6.Image RadioButtonImage RadioButton
7.RadioButton click eventRadioButton click event
8.Use RadioButton to control TextBox alignmentUse RadioButton to control TextBox alignment
9.RadioButton checked event handlerRadioButton checked event handler