Problems pausing and restarting animations in XAML
-
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>
-
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>
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
-
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
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.
-
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.
-
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
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.
-
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.
-
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
I cheated and solved it:
-
I cheated and solved it: