View Issue Details

IDProjectCategoryView StatusLast Update
0002116NoesisGUIC# SDKpublic2021-09-20 23:47
Reporterai_enabled Assigned Tosfernandez  
PrioritynormalSeveritymajor 
Status assignedResolutionopen 
Product Version3.1.1 
Summary0002116: Storyboard from Template is shared between UserControl instances causing an issue with Completed event
Description

Hi guys,
compared to v3.0 there is a new bug with Storyboards.
For example we have a GameWindow (UserControl) that has custom template. In its Initialized event handler we're using:


his.storyboardOpen = (Storyboard)this.Template.Resources["StoryboardOpen"];

Then in its Loaded event handler we're subscribing to this event:

this.storyboardOpen.Completed += this.StoryboardOpenCompletedHandler;

So far so good, except that storyboardOpen is the same instance for all GameWindow instances. So when Completed event is invoked for any animated GameWindow, all GameWindow instances are notified via their StoryboardOpenCompletedHandler about the storyboard completion.

There was no such bug in NoesisGUI v3.0.

Regards!

PlatformAny

Activities

sfernandez

sfernandez

2021-09-20 12:04

manager   ~0007459

I tried to replicate this in WPF and it turns out that Storyboards defined in a Template.Resources are frozen, so you cannot add a handler to the Completed event (we should fix this, as Noesis is not complaining).

InvalidOperationException: Specified value of type 'System.Windows.Media.Animation.Storyboard' must have IsFrozen set to false to modify.

It fails even if you try to use a StoryboardCompletedTrigger with that storyboard.

To avoid this, and as you are manually starting and stopping the animation, you can create a Clone() from the Template Storyboard for each window to control it:

this.storyboardOpen = ((Storyboard)this.Template.Resources["StoryboardOpen"]).Clone();

ai_enabled

ai_enabled

2021-09-20 12:10

updater   ~0007460

Hi Sergio,
thank you! Are you certain that the Clone method is available and implemented properly for this scenario? It was the first thing I thought of before reporting the issue but it didn't work. Please verify.

The InvalidOperationException certainly would be very useful!

Once you finish with the other remaining issues I will pull the changes and test everything including this solution.

Regards!

sfernandez

sfernandez

2021-09-20 16:27

manager   ~0007461

Yes, the Clone of Storyboard works as expected in Noesis, I just verified it.

ai_enabled

ai_enabled

2021-09-20 23:46

updater   ~0007465

Last edited: 2021-09-20 23:47

Thank you! I can confirm that Clone is indeed implemented and works as expected.
You need to add this method to Storyboard class in order to match WPF API:

public new Storyboard Clone() => (Storyboard)base.Clone();

The current Clone method is implemented only in the base Freezable class so calling it will return an instance of Freezable class while in WPF a separate method is invoked returning a Storyboard.
I guess you may need to do the same for other resource types as well to match WPF API.

Regards!

Issue History

Date Modified Username Field Change
2021-09-17 16:07 ai_enabled New Issue
2021-09-17 16:08 ai_enabled Description Updated
2021-09-17 16:08 ai_enabled Description Updated
2021-09-20 12:04 sfernandez Assigned To => sfernandez
2021-09-20 12:04 sfernandez Status new => feedback
2021-09-20 12:04 sfernandez Note Added: 0007459
2021-09-20 12:10 ai_enabled Note Added: 0007460
2021-09-20 12:10 ai_enabled Status feedback => assigned
2021-09-20 16:27 sfernandez Status assigned => feedback
2021-09-20 16:27 sfernandez Note Added: 0007461
2021-09-20 23:46 ai_enabled Note Added: 0007465
2021-09-20 23:46 ai_enabled Status feedback => assigned
2021-09-20 23:47 ai_enabled Note Edited: 0007465