Animate Opacity : Color Animation « Windows Presentation Foundation « C# / CSharp Tutorial






<Window x:Class="Animation.AnimateVisual"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="AnimateVisualBrush" Height="300" Width="300" Background="LightGoldenrodYellow">
    <Grid>
      <Grid.RowDefinitions>
        <RowDefinition></RowDefinition>
        <RowDefinition></RowDefinition>
      </Grid.RowDefinitions>

      <Button Name="visual" HorizontalAlignment="Center" VerticalAlignment="Center">
        <Button.Content>Test</Button.Content>
        <Button.Triggers>
          <EventTrigger RoutedEvent="Button.Click">
            <BeginStoryboard>
              <Storyboard  RepeatBehavior="Forever">
                <DoubleAnimation Storyboard.TargetName="rectangle"
                                 Storyboard.TargetProperty="Opacity"
                                 To="0.1" Duration="0:0:4" AutoReverse="True"></DoubleAnimation>

              </Storyboard>
            </BeginStoryboard>
          </EventTrigger>
        </Button.Triggers>
      </Button>
      
      <Rectangle Grid.Row="1" Name="rectangle" Width="100" Stretch="Uniform" ClipToBounds="False" RenderTransformOrigin="0.5,0.5">
        <Rectangle.Fill>
          <VisualBrush Visual="{Binding ElementName=visual}">
          </VisualBrush>
        </Rectangle.Fill>
      </Rectangle>
    </Grid>
  </Window>
WPF Animate Opacity








24.109.Color Animation
24.109.1.Animate RadialGradientAnimate RadialGradient
24.109.2.Animate OpacityAnimate Opacity
24.109.3.Animate GradientStop and Button controlAnimate GradientStop and Button control
24.109.4.Animate the Color of a Brush with Indirect Property TargetingAnimate the Color of a Brush with Indirect Property Targeting
24.109.5.Opacity AnimationOpacity Animation
24.109.6.Animate the background colorAnimate the background color
24.109.7.Animate the brush's RadiusX property.Animate the brush's RadiusX property.