Issue with StoryboardCompletedTrigger not calling the InvokeCommandAction action
Hello
I was trying to use StoryboardCompletedTrigger but however StoryboardCompletedTrigger.StoryboardChanged is correctly called and the event is attached but when the storyboard ends, it doesn't call the function.
Is there a specific way to use this StoryboardCompletedTrigger and call a method?
Thank you
I was trying to use StoryboardCompletedTrigger but however StoryboardCompletedTrigger.StoryboardChanged is correctly called and the event is attached but when the storyboard ends, it doesn't call the function.
Code: Select all
<Grid Name="PART_mainGridLayout" >
<Grid.Resources>
<Storyboard x:Key="LocationFanfare" >
...
</Storyboard>
</Grid.Resources>
<Grid.Triggers>
<EventTrigger RoutedEvent="FrameworkElement.Loaded">
<BeginStoryboard Storyboard="{StaticResource LocationFanfare}" />
</EventTrigger>
</Grid.Triggers>
<i:Interaction.Triggers>
<!-- DOESN T WORK-->
<ei:StoryboardCompletedTrigger Storyboard="{StaticResource LocationFanfare}">
<i:InvokeCommandAction Command="{Binding NewLocationStoryboardCompletedCommand}"/>
</ei:StoryboardCompletedTrigger>
</i:Interaction.Triggers>
</Grid>
Thank you
-
sfernandez
Site Admin
- Posts: 2997
- Joined:
Re: Issue with StoryboardCompletedTrigger not calling the InvokeCommandAction action
Hi, I replicated your code in the following xamltoy and it seems to work:
Could you add another action (something obvious like changing the Width of an element or some text) to the StoryboardCompletedTrigger to see if that action works?
Is it possible that the binding to 'NewLocationStoryboardCompletedCommand' is not resolved? is that property part of Grid's DataContext
Could you add another action (something obvious like changing the Width of an element or some text) to the StoryboardCompletedTrigger to see if that action works?
Is it possible that the binding to 'NewLocationStoryboardCompletedCommand' is not resolved? is that property part of Grid's DataContext
Re: Issue with StoryboardCompletedTrigger not calling the InvokeCommandAction action
Hello!
Sorry for the delay in my reply.
I have tested your behavior and unfortunately it is the whole StoryboardCompletedTrigger that seems not to trigger at the end of the animation (even a simple ChangePropertyAction wouldn't change the color of a background for example).
If this makes a difference, the whole element is in a DataTemplate that is included in a ContentControl with a storyboard triggering on FrameworkElement.OnLoaded in the DataTemplate.
PS : I did a workaround using a DataTrigger listening on a property animated by the storyboard itself but that's a hack more than anything else.
Sorry for the delay in my reply.
I have tested your behavior and unfortunately it is the whole StoryboardCompletedTrigger that seems not to trigger at the end of the animation (even a simple ChangePropertyAction wouldn't change the color of a background for example).
If this makes a difference, the whole element is in a DataTemplate that is included in a ContentControl with a storyboard triggering on FrameworkElement.OnLoaded in the DataTemplate.
PS : I did a workaround using a DataTrigger listening on a property animated by the storyboard itself but that's a hack more than anything else.
-
sfernandez
Site Admin
- Posts: 2997
- Joined:
Re: Issue with StoryboardCompletedTrigger not calling the InvokeCommandAction action
As I mentioned in our mail conversation this is related to this known issue with templates and StaticResources: #1822
The workaround, explained in that ticket, is to use Bindings to reference the storyboard so it gets resolved once the template is applied and it returns the correct object:
The workaround, explained in that ticket, is to use Bindings to reference the storyboard so it gets resolved once the template is applied and it returns the correct object:
Code: Select all
<ControlTemplate TargetType="Control">
<Grid x:Name="root">
<Grid.Resources>
<ImageBrush x:Key="imgBrush" ImageSource="Test.png"/>
</Grid.Resources>
<Rectangle x:Name="rect" Fill="{Binding Resources[imgBrush], ElementName=root}"/>
</Grid>
</ControlTemplate>
Who is online
Users browsing this forum: No registered users and 16 guests