ThisIsMyUserName
Topic Author
Posts: 6
Joined: 01 Mar 2023, 11:05

PropertyChangedTriggers all firing on game load

04 Aug 2023, 19:09

I have a DataTemplate containing multiple storyboards all hooked up to PropertyChangedTriggers. But when I load the game it seems like the all of these triggers are being trigger by the instantiation of the associated variable.
Other than this, the PropertyChangedTriggers all work as expected. Am I setting these Triggers up incorrectly?

Below is an example of the code I'm using. I am seeing both of the storyboard playing as soon as an example of the DataTemplate is created in game

Xaml Implementation of Storyboard and triggers within DataTemplate
<Grid.Resources>
	<Storyboard x:Key="DataTemplate_Timeline_IN">
		<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="ScaleX" Storyboard.TargetName="Element1_Scale">
			<EasingDoubleKeyFrame KeyTime="0" Value="0.8"/>
			<EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="1.2"/>
			<EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="1"/>
		</DoubleAnimationUsingKeyFrames>
	
		<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="ScaleY" Storyboard.TargetName="Element1_Scale">
			<EasingDoubleKeyFrame KeyTime="0" Value="0.8"/>
			<EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="1.2"/>
			<EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="1"/>
		</DoubleAnimationUsingKeyFrames>
		
		<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="Element1">
			<EasingDoubleKeyFrame KeyTime="0" Value="0"/>
			<EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="0.8"/>
		</DoubleAnimationUsingKeyFrames>
	</Storyboard>
	
	<Storyboard x:Key="DataTemplate_Timeline_Highlight">
		<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="Element2">
			<EasingDoubleKeyFrame KeyTime="0" Value="0"/>
			<EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="1.0"/>
		</DoubleAnimationUsingKeyFrames>
	</Storyboard>
</Grid.Resources>

<b:Interaction.Triggers>
	<b:PropertyChangedTrigger Binding="{Binding DataTimelineInAnim}">
		<b:ControlStoryboardAction ControlStoryboardOption="Play" Storyboard="{StaticResource DataTemplate_Timeline_IN}"/>
	</b:PropertyChangedTrigger>
	
	<b:PropertyChangedTrigger Binding="{Binding DataTimelineHighlightAnim}">
		<b:ControlStoryboardAction ControlStoryboardOption="Play" Storyboard="{StaticResource DataTemplate_Timeline_Highlight}"/>
	</b:PropertyChangedTrigger>
</b:Interaction.Triggers>
Unreal C++ MyDataTemplate.h declaration of Property variables

	UPROPERTY()
	bool DataTimelineInAnim = false;
	UPROPERTY()
	bool DataTimelineHighlightAnim = false;
	

Unreal C++ MyDataTemplate.cpp (the only place the variables are referenced). Even if these functions are not called, the Storyboards still play
void UAwarenessIndicatorData::Play_DataTimelineInAnim ()
{
	DataTimelineInAnim  = !DataTimelineInAnim ;
	NoesisNotifyPropertyChanged(this, "DataTimelineInAnim ");
}
Unreal C++ MyDataTemplate.cpp (creating the DataTemplate object and adding it to a list)
	MyDataTemplate = CreateDataModel<UMyDataTemplate>("");
		
	ViewModel->MyList.Add(MyDataTemplate );
	NoesisNotifyArrayPropertyPostAdd(&ViewModel->MyList);
 
User avatar
sfernandez
Site Admin
Posts: 3109
Joined: 22 Dec 2011, 19:20

Re: PropertyChangedTriggers all firing on game load

06 Aug 2023, 19:11

I'll have to verify the behavior in WPF but I think it is expected as it triggers when the binding is evaluated for the first time.

In the meantime you can try to disable the actions until the control is loaded for example:
<b:Interaction.Triggers>
  <b:PropertyChangedTrigger Binding="{Binding DataTimelineInAnim}">
    <b:ControlStoryboardAction x:Name="PlayInAction" IsEnabled="False"
                 ControlStoryboardOption="Play" Storyboard="{StaticResource DataTemplate_Timeline_IN}"/>
  </b:PropertyChangedTrigger>
	
  <b:PropertyChangedTrigger Binding="{Binding DataTimelineHighlightAnim}">
    <b:ControlStoryboardAction x:Name="HighlightAction" IsEnabled="False"
                 ControlStoryboardOption="Play" Storyboard="{StaticResource DataTemplate_Timeline_Highlight}"/>
  </b:PropertyChangedTrigger>
	
  <b:EventTrigger EventName="Loaded">
    <b:ChangePropertyAction TargetName="PlayInAction" PropertyName="IsEnabled" Value="True"/>
    <b:ChangePropertyAction TargetName="HightlightAction" PropertyName="IsEnabled" Value="True"/>
  </b:EventTrigger>
</b:Interaction.Triggers>
 
ThisIsMyUserName
Topic Author
Posts: 6
Joined: 01 Mar 2023, 11:05

Re: PropertyChangedTriggers all firing on game load

08 Aug 2023, 09:41

That has done the trick for now, thank you. I was previously calling the In Storyboard on the same frame I created the object, but a single frame delay isn't much of an issue for now

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot] and 2 guests