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. Problems pausing and restarting animations in XAML

Problems pausing and restarting animations in XAML

Scheduled Pinned Locked Moved WPF
wpfwcfhelp
8 Posts 2 Posters 3 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.
  • K Offline
    K Offline
    Kenneth Haugland
    wrote on last edited by
    #1

    As per title, I assume that is the problem. My XAML is the following:

        <Setter Property="FontWeight" Value="Normal"/>
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding Mode=OneWay,ElementName=PopupChild,Path=IsOpen}" Value="True">
                                <Setter Property="FontWeight" Value="Bold"/>
                            </DataTrigger>
                        </Style.Triggers>
    
    L 1 Reply Last reply
    0
    • K Kenneth Haugland

      As per title, I assume that is the problem. My XAML is the following:

          <Setter Property="FontWeight" Value="Normal"/>
                          <Style.Triggers>
                              <DataTrigger Binding="{Binding Mode=OneWay,ElementName=PopupChild,Path=IsOpen}" Value="True">
                                  <Setter Property="FontWeight" Value="Bold"/>
                              </DataTrigger>
                          </Style.Triggers>
      
      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Did you try setting popup's .IsOpen to false in the button handler? One might assume popup is not "seeing" the button clicks due to the event routing in this case. You could try adding a Button.Click handler on the popup if you can go with a common handler.

      "(I) am amazed to see myself here rather than there ... now rather than then". ― Blaise Pascal

      K 1 Reply Last reply
      0
      • L Lost User

        Did you try setting popup's .IsOpen to false in the button handler? One might assume popup is not "seeing" the button clicks due to the event routing in this case. You could try adding a Button.Click handler on the popup if you can go with a common handler.

        "(I) am amazed to see myself here rather than there ... now rather than then". ― Blaise Pascal

        K Offline
        K Offline
        Kenneth Haugland
        wrote on last edited by
        #3

        I did try out this:

                    <Style.Triggers>
                                    <EventTrigger RoutedEvent="Click">
                                        <BeginStoryboard Name="closing" Storyboard="{StaticResource ImidiateClosePopupAnimation}"/>
                                    </EventTrigger>
                                </Style.Triggers>
        

        But that throws an error saying that:

        Quote:

        Cannot resolve all property references in the property path 'IsOpen'. Verify that applicable objects support the properties.

        I couldnt figure out what the problem was: wpf - Cannot resolve all property references in the propertypath - Stack Overflow[^] The button click does swallow the button pressed, and although I can use PreviewMouseDown, that will stop the click event. I could put all of this in a UserControl and hardcode everything, but this seemed very doable in XAML, or so I thought.

        L 1 Reply Last reply
        0
        • K Kenneth Haugland

          I did try out this:

                      <Style.Triggers>
                                      <EventTrigger RoutedEvent="Click">
                                          <BeginStoryboard Name="closing" Storyboard="{StaticResource ImidiateClosePopupAnimation}"/>
                                      </EventTrigger>
                                  </Style.Triggers>
          

          But that throws an error saying that:

          Quote:

          Cannot resolve all property references in the property path 'IsOpen'. Verify that applicable objects support the properties.

          I couldnt figure out what the problem was: wpf - Cannot resolve all property references in the propertypath - Stack Overflow[^] The button click does swallow the button pressed, and although I can use PreviewMouseDown, that will stop the click event. I could put all of this in a UserControl and hardcode everything, but this seemed very doable in XAML, or so I thought.

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          For me, if I can get there with less stress using some code-behind, I'll go with the code-behind. I need to ship; sometimes daily.

          "(I) am amazed to see myself here rather than there ... now rather than then". ― Blaise Pascal

          K 1 Reply Last reply
          0
          • L Lost User

            For me, if I can get there with less stress using some code-behind, I'll go with the code-behind. I need to ship; sometimes daily.

            "(I) am amazed to see myself here rather than there ... now rather than then". ― Blaise Pascal

            K Offline
            K Offline
            Kenneth Haugland
            wrote on last edited by
            #5

            Yeah, but this is really bugging me out. I did get it to work, sort of:

                   <Style.Triggers>
                                    <MultiDataTrigger>
                                        <MultiDataTrigger.Conditions>
                                            <Condition Binding="{Binding Mode=OneWay,ElementName=PopupParent,Path=IsMouseOver}" Value="False"/>
                                            <Condition Binding="{Binding Mode=OneWay,ElementName=PopupChild,Path=IsMouseOver}" Value="False"/>
                                        </MultiDataTrigger.Conditions>
                                        <MultiDataTrigger.EnterActions>
                                            <BeginStoryboard Storyboard="{StaticResource ClosePopupAnimation}"/>
                                        </MultiDataTrigger.EnterActions>
                                        <MultiDataTrigger.ExitActions>
                                            <BeginStoryboard Storyboard="{StaticResource OpenPopupAnimation}"/>
                                        </MultiDataTrigger.ExitActions>
                                    </MultiDataTrigger>
                                    <EventTrigger RoutedEvent="Button.Click">
                                        <BeginStoryboard Storyboard="{StaticResource ClosePopupAnimation}"/>
                                    </EventTrigger>
                                </Style.Triggers>
            

            But now the popup wont open again after I clicked the button.

            L 1 Reply Last reply
            0
            • K Kenneth Haugland

              Yeah, but this is really bugging me out. I did get it to work, sort of:

                     <Style.Triggers>
                                      <MultiDataTrigger>
                                          <MultiDataTrigger.Conditions>
                                              <Condition Binding="{Binding Mode=OneWay,ElementName=PopupParent,Path=IsMouseOver}" Value="False"/>
                                              <Condition Binding="{Binding Mode=OneWay,ElementName=PopupChild,Path=IsMouseOver}" Value="False"/>
                                          </MultiDataTrigger.Conditions>
                                          <MultiDataTrigger.EnterActions>
                                              <BeginStoryboard Storyboard="{StaticResource ClosePopupAnimation}"/>
                                          </MultiDataTrigger.EnterActions>
                                          <MultiDataTrigger.ExitActions>
                                              <BeginStoryboard Storyboard="{StaticResource OpenPopupAnimation}"/>
                                          </MultiDataTrigger.ExitActions>
                                      </MultiDataTrigger>
                                      <EventTrigger RoutedEvent="Button.Click">
                                          <BeginStoryboard Storyboard="{StaticResource ClosePopupAnimation}"/>
                                      </EventTrigger>
                                  </Style.Triggers>
              

              But now the popup wont open again after I clicked the button.

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              I'm not sure that trying to manipulate the animation itself is better than working with .IsOpen. All will affect the "state" of things in different ways.

              "(I) am amazed to see myself here rather than there ... now rather than then". ― Blaise Pascal

              K 1 Reply Last reply
              0
              • L Lost User

                I'm not sure that trying to manipulate the animation itself is better than working with .IsOpen. All will affect the "state" of things in different ways.

                "(I) am amazed to see myself here rather than there ... now rather than then". ― Blaise Pascal

                K Offline
                K Offline
                Kenneth Haugland
                wrote on last edited by
                #7

                I cheated and solved it:

                L 1 Reply Last reply
                0
                • K Kenneth Haugland

                  I cheated and solved it:

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #8

                  If there are no side-effects, works for me too.

                  "(I) am amazed to see myself here rather than there ... now rather than then". ― Blaise Pascal

                  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