tags:

views:

267

answers:

1

Hi,

I am creating an animation using story board and entire thing is inside a ItemsControl,when i start the application the animation starts, but i want an ability to stop the animation as soon as we receive a value from the database. How do i get hold of a particular story board inside an ItemsControl template so that i can stop it in my code behind. Or is there a property that i can data bind and use in code behind.

Currently my code look like this

 <StackPanel 
     x:Name="spStart"
     Margin="0,10,5,0">
  <Image x:Name="Round" Source="Images/Start.png"
    Height="35"
    Stretch="Uniform"  
    ToolTipService.ToolTip="Start"
    RenderTransformOrigin="0.5,0.5">
    <Image.RenderTransform>
      <TransformGroup>
        <RotateTransform/>
      </TransformGroup>
    </Image.RenderTransform>

    <Image.Triggers> 
      <EventTrigger RoutedEvent="Grid.Loaded">
        <BeginStoryboard>
          <Storyboard x:Name="RotatingStory" Completed="myStoryboard_Completed"
            x:Uid="{Binding FileReceived}">
            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00"  
              Storyboard.TargetName="Round"
              Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(RotateTransform.Angle)">
              <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
              <SplineDoubleKeyFrame KeyTime="00:00:03" Value="360"/>
            </DoubleAnimationUsingKeyFrames>
          </Storyboard>
        </BeginStoryboard>
      </EventTrigger>
    </Image.Triggers>
  </Image>
</StackPanel>
+1  A: 

Looking at the documentation have tried this:-

 var sb = ((BeginStoryBoard)Round.Triggers[0].Actions[0]).Storyboard;
 sb.Stop;  // Or whatever else you want to do the storyboard such as SkipToFill.
AnthonyWJones
I had to do something like this TriggerActionCollection actions = ((System.Windows.EventTrigger)(Round.Triggers[0])).Actions;BeginStoryboard sbBeing = (BeginStoryboard)actions[0];but in which event should i put this code in ?
rsapru
Thanks a lot figured it out.
rsapru