mshvern23
Topic Author
Posts: 35
Joined: 22 May 2023, 02:00

Firing multiple storyboards noesis:DataEventTrigger

14 Jun 2023, 01:29

Am I using `noesis:DataEventTrigger` incorrectly?

I've created a simple storyboard that draws a line using `TrimEnd`.
I populate ItemsControl with a list from an Unreal property, each object is defined as the following:
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnDrawLineDelegate);
class UGameMapLine : public UObject
{
...
	UPROPERTY(BlueprintAssignable, BlueprintCallable)
	FOnDrawLineDelegate OnDraw;
...
When I call this `OnDraw` in Blueprint for any of the instances in the array, it stops the Storyboard for all other instances. I.e. if I were to call `OnDraw` on 100 instances of `UGameMapLine`, the animation would only play on the last instance. If I were to wait for the whole length of the animation in between each call, I would be able to play all of the animations sequentially, but I can never play two or more at the same time.
            <b:Interaction.Triggers>
                <noesis:DataEventTrigger Source="{Binding}" EventName="OnDraw">
                    <b:ControlStoryboardAction Storyboard="{StaticResource Anim.Draw}"/>
                </noesis:DataEventTrigger>
            </b:Interaction.Triggers>
If I substitute this with the following, every instance plays the animation simultaneously as you'd expect.
        <ControlTemplate.Triggers>
            <EventTrigger RoutedEvent="FrameworkElement.Loaded">
                <BeginStoryboard Storyboard="{StaticResource Anim.Draw}"/>
            </EventTrigger>
        </ControlTemplate.Triggers>

More info if additional context is needed:

The list of `Lines` is declared on a View and used to populate an items control.
                        <ItemsControl ItemsSource="{Binding Lines}">
                            <ItemsControl.ItemsPanel>
                                <ItemsPanelTemplate>
                                    <Canvas />
                                </ItemsPanelTemplate>
                            </ItemsControl.ItemsPanel>
                            <ItemsControl.ItemTemplate>
                                <DataTemplate>
                                    <ContentControl Content="{Binding}" Template="{StaticResource Template.Route}" Style="{StaticResource Style.Route}">
                                        <!--<b:Interaction.Triggers>
                                            <noesis:DataEventTrigger Source="{Binding}" EventName="OnDraw">
                                                <b:ControlStoryboardAction Storyboard="{StaticResource Anim.Draw}"/>
                                            </noesis:DataEventTrigger>
                                        </b:Interaction.Triggers>-->
                                    </ContentControl>
                                </DataTemplate>
                            </ItemsControl.ItemTemplate>
                        </ItemsControl>
The template is defined like this:
ControlTemplate x:Key="Template.Route" TargetType="{x:Type ContentControl}">
        <ControlTemplate.Resources>
            <Storyboard x:Key="Anim.Draw">
                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(noesis:Path.TrimEnd)" Storyboard.TargetName="Path0">
                    <DiscreteDoubleKeyFrame KeyTime="0" Value="1"/>
                    <SplineDoubleKeyFrame KeySpline="0.586,0 0.418,1" KeyTime="0:0:0.5" Value="0"/>
                </DoubleAnimationUsingKeyFrames>
            </Storyboard>
        </ControlTemplate.Resources>
        <ControlTemplate.Triggers>
            <EventTrigger RoutedEvent="FrameworkElement.Loaded">
                <BeginStoryboard Storyboard="{StaticResource Anim.Draw}"/>
            </EventTrigger>
        </ControlTemplate.Triggers>
        <Grid x:Name="Root" DataContext="{Binding}">
            <b:Interaction.Triggers>
                <noesis:DataEventTrigger Source="{Binding}" EventName="OnDraw">
                    <b:ControlStoryboardAction Storyboard="{StaticResource Anim.Draw}"/>
                </noesis:DataEventTrigger>
            </b:Interaction.Triggers>
            ...
The rest of the `Grid` contains my layout which is probably not important.
 
User avatar
sfernandez
Site Admin
Posts: 3363
Joined: 22 Dec 2011, 19:20

Re: Firing multiple storyboards noesis:DataEventTrigger

15 Jun 2023, 10:27

Hi, nothing wrong on your side. It seems there is a bug in the ControlStoryboardAction when used inside templates and references a Storyboard from the template or outside of it. Could you please report it in our bugtracker?

In the meantime it should work if you define the Storyboard inside the visual tree of the template, something like this:
<ControlTemplate x:Key="Template.Route" TargetType="{x:Type ContentControl}">
  <Grid x:Name="Root">
    <Grid.Resources>
      <Storyboard x:Key="Anim.Draw">
        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(noesis:Path.TrimEnd)" Storyboard.TargetName="Path0">
          <DiscreteDoubleKeyFrame KeyTime="0" Value="1"/>
          <SplineDoubleKeyFrame KeySpline="0.586,0 0.418,1" KeyTime="0:0:0.5" Value="0"/>
        </DoubleAnimationUsingKeyFrames>
      </Storyboard>
    </Grid.Resources>
    <b:Interaction.Triggers>
      <b:EventTrigger EventName="Loaded">
        <b:ControlStoryboardAction Storyboard="{StaticResource Anim.Draw}"/>
      </b:EventTrigger>
      <noesis:DataEventTrigger Source="{Binding}" EventName="OnDraw">
        <b:ControlStoryboardAction Storyboard="{StaticResource Anim.Draw}"/>
      </noesis:DataEventTrigger>
    </b:Interaction.Triggers>
    ...
  </Grid>
</ControlTemplate>

Who is online

Users browsing this forum: No registered users and 4 guests