jinfox
Topic Author
Posts: 13
Joined: 06 Apr 2019, 00:11

Issue with StoryboardCompletedTrigger not calling the InvokeCommandAction action

10 May 2021, 15:14

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.
<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>
Is there a specific way to use this StoryboardCompletedTrigger and call a method?

Thank you

Tags:
 
User avatar
sfernandez
Site Admin
Posts: 2207
Joined: 22 Dec 2011, 19:20

Re: Issue with StoryboardCompletedTrigger not calling the InvokeCommandAction action

13 May 2021, 10:30

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
 
jinfox
Topic Author
Posts: 13
Joined: 06 Apr 2019, 00:11

Re: Issue with StoryboardCompletedTrigger not calling the InvokeCommandAction action

26 May 2021, 12:15

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.
 
User avatar
sfernandez
Site Admin
Posts: 2207
Joined: 22 Dec 2011, 19:20

Re: Issue with StoryboardCompletedTrigger not calling the InvokeCommandAction action

27 May 2021, 11:22

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:
<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: Google [Bot] and 2 guests