Remove aniamtion with RemoveStoryboard : DoubleAnimation « Windows Presentation Foundation « C# / C Sharp






Remove aniamtion with RemoveStoryboard

Remove aniamtion with RemoveStoryboard
  
<Window x:Class="Wpf1Application.Window1"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  Title="" Height="300" Width="300">
  <Window.Resources>
    <Storyboard x:Key="Storyboard1">
      <ParallelTimeline>
        <DoubleAnimation x:Name="Animation1" Storyboard.TargetProperty="Width" From="140" To="50"
          AutoReverse="True" RepeatBehavior="Forever" />
        <DoubleAnimation Storyboard.TargetProperty="Opacity" To="0.5" AutoReverse="True" RepeatBehavior="Forever" />
      </ParallelTimeline>
    </Storyboard>
  </Window.Resources>

  <UniformGrid>
    <Button Margin="5" Content="Method 1">
      <Button.Triggers>
        <EventTrigger RoutedEvent="Button.Loaded">
          <BeginStoryboard Storyboard="{DynamicResource Storyboard1}" x:Name="BeginStoryboard1" />
        </EventTrigger>
        <EventTrigger RoutedEvent="Button.Click">
          <RemoveStoryboard BeginStoryboardName="BeginStoryboard1" />
        </EventTrigger>
      </Button.Triggers>
    </Button>
  </UniformGrid>
</Window>

   
    
  








Related examples in the same category

1.Animated transformAnimated transform
2.Create DoubleAnimation and Animate a Button with Button.BeginAnimation and Button.WidthPropertyCreate DoubleAnimation and Animate a Button with Button.BeginAnimation and Button.WidthProperty
3.DoubleAnimation Loop foreverDoubleAnimation Loop forever
4.DoubleAnimation Loop three timesDoubleAnimation Loop three times
5.DoubleAnimation Loop for 30 secondsDoubleAnimation Loop for 30 seconds
6.TranslateTransform and DoubleAnimationTranslateTransform and DoubleAnimation
7.Path Animation with DoubleAnimationUsingPath, AutoReversePath Animation with DoubleAnimationUsingPath, AutoReverse