Storyboard not playing on DataTemplate in ItemsControl with DataTriggers in Unreal Engine
Posted: 20 Jun 2023, 17:14
I have a list of items in an ItemsControl.
When I remove an item from the list I trigger an event to play a removal storyboard - this works as expected.
However, if I try to trigger the storyboard on any other item that was in the list the storyboard doesn't play
If I remove all items from the list and add new items the storyboard will play on only one of the items as before
If I add a new item the storyboard will on the new item but not on the existing ones.
What am I doing wrong?
Data Template, with containing Storyboard and Data Event Trigger
The DataTemplates are displayed in the page using an ItemsControl
In the C++ I am storing my objects in a TArray and selecting the object in the list by index. The events are then called by the object
Viewmodel.h
ViewModel.cpp
ObjectiveData.cpp
When I remove an item from the list I trigger an event to play a removal storyboard - this works as expected.
However, if I try to trigger the storyboard on any other item that was in the list the storyboard doesn't play
If I remove all items from the list and add new items the storyboard will play on only one of the items as before
If I add a new item the storyboard will on the new item but not on the existing ones.
What am I doing wrong?
Data Template, with containing Storyboard and Data Event Trigger
Code: Select all
<DataTemplate x:Key="Objective">
<Grid x:Name="Item" Height="30" Width="800" HorizontalAlignment="Left" VerticalAlignment="Top" Opacity="0.5">
<Grid.RenderTransform>
<TranslateTransform x:Name="Item_TranslateTransform" X="0" Y="0"/>
</Grid.RenderTransform>
<Grid.Resources>
<Storyboard x:Key="Item_timeline_OUT">
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="X" Storyboard.TargetName="Item_TranslateTransform">
<EasingDoubleKeyFrame KeyTime="0" Value="0"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.7" Value="108.667"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="Item">
<EasingDoubleKeyFrame KeyTime="0" Value="1"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="1"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.7" Value="0"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</Grid.Resources>
<b:Interaction.Triggers>
<noesis:DataEventTrigger Source="{Binding}" EventName="OutAnim">
<b:ControlStoryboardAction ControlStoryboardOption="Play" Storyboard="{StaticResource Item_timeline_OUT}"/>
</noesis:DataEventTrigger>
</b:Interaction.Triggers>
</Grid>
</DataTemplate>
The DataTemplates are displayed in the page using an ItemsControl
Code: Select all
<ItemsControl ItemsSource="{Binding Objectives}" ItemTemplate="{StaticResource Objective}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>Viewmodel.h
Code: Select all
UPROPERTY()
TArray<UObjectiveData*> Objectives;Code: Select all
Objectives[index]->PlayOutAnim();Code: Select all
void UObjectiveData::PlayOutAnim() const
{
OutAnim.Broadcast();
}