Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WPF
  4. [WPF] How to Stop an Animation

[WPF] How to Stop an Animation

Scheduled Pinned Locked Moved WPF
wpfquestioncsharptutorial
6 Posts 5 Posters 28 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Richard Andrew x64R Offline
    Richard Andrew x64R Offline
    Richard Andrew x64
    wrote on last edited by
    #1

    It appears that the Storyboard won't accept a new RepeatBehavior structure once the animation has already begun. I want to have an animation repeat endlessly, until the user clicks the window. I have the animation RepeatBehavior set to Forever in the XAML. How do I stop the animation once it's begun?

    The difficult we do right away... ...the impossible takes slightly longer.

    V A M M 4 Replies Last reply
    0
    • Richard Andrew x64R Richard Andrew x64

      It appears that the Storyboard won't accept a new RepeatBehavior structure once the animation has already begun. I want to have an animation repeat endlessly, until the user clicks the window. I have the animation RepeatBehavior set to Forever in the XAML. How do I stop the animation once it's begun?

      The difficult we do right away... ...the impossible takes slightly longer.

      V Offline
      V Offline
      Venkatesh Mookkan
      wrote on last edited by
      #2

      Change the RepeatBehavior and call Stop()

      Venkatesh Mookkan (My Recent Article: WPF Custom Control - FilterControl for ListBox/ListView)

      Richard Andrew x64R 1 Reply Last reply
      0
      • V Venkatesh Mookkan

        Change the RepeatBehavior and call Stop()

        Venkatesh Mookkan (My Recent Article: WPF Custom Control - FilterControl for ListBox/ListView)

        Richard Andrew x64R Offline
        Richard Andrew x64R Offline
        Richard Andrew x64
        wrote on last edited by
        #3

        Thanks.

        The difficult we do right away... ...the impossible takes slightly longer.

        1 Reply Last reply
        0
        • Richard Andrew x64R Richard Andrew x64

          It appears that the Storyboard won't accept a new RepeatBehavior structure once the animation has already begun. I want to have an animation repeat endlessly, until the user clicks the window. I have the animation RepeatBehavior set to Forever in the XAML. How do I stop the animation once it's begun?

          The difficult we do right away... ...the impossible takes slightly longer.

          A Offline
          A Offline
          Abhinav S
          wrote on last edited by
          #4

          A Stop() call on the StoryBoard should be sufficient. You don't need to do anything else.

          The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.

          1 Reply Last reply
          0
          • Richard Andrew x64R Richard Andrew x64

            It appears that the Storyboard won't accept a new RepeatBehavior structure once the animation has already begun. I want to have an animation repeat endlessly, until the user clicks the window. I have the animation RepeatBehavior set to Forever in the XAML. How do I stop the animation once it's begun?

            The difficult we do right away... ...the impossible takes slightly longer.

            M Offline
            M Offline
            Mark Salsbery
            wrote on last edited by
            #5

            Another alternative maybe...all in XAML...

            <Grid Name="theGrid" Background="SteelBlue" >
                <Grid.Triggers>
                    <EventTrigger RoutedEvent="Grid.Loaded">
                        <BeginStoryboard x:Name="gridBeginStoryboard" >
                            <Storyboard>
                                <DoubleAnimation Storyboard.TargetName="theGrid" 
                                                 Storyboard.TargetProperty="Opacity"
                                                 From="1.0" To="0.0" Duration="0:0:2" 
                                                 AutoReverse="True" RepeatBehavior="Forever" />
                            </Storyboard>
                        </BeginStoryboard>
                    </EventTrigger>
                    <EventTrigger SourceName="theGrid" RoutedEvent="Grid.MouseLeftButtonDown">
                        <StopStoryboard BeginStoryboardName="gridBeginStoryboard" />
                    </EventTrigger>
                </Grid.Triggers>
            </Grid>
            

            Mark Salsbery Microsoft MVP - Visual C++ :java:

            1 Reply Last reply
            0
            • Richard Andrew x64R Richard Andrew x64

              It appears that the Storyboard won't accept a new RepeatBehavior structure once the animation has already begun. I want to have an animation repeat endlessly, until the user clicks the window. I have the animation RepeatBehavior set to Forever in the XAML. How do I stop the animation once it's begun?

              The difficult we do right away... ...the impossible takes slightly longer.

              M Offline
              M Offline
              Minh Hai Phan
              wrote on last edited by
              #6

              u can create a doubleanimation type, and then set douleanimation type equals(storyboard)Findresource("name of storyboard"); and doubleanimation.stop()..

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups