Asked by:
Template change crashes application due to UI animation running

General discussion
-
I have an animation that animates some colors when the mouse moves in and out of a control. This is all in XAML and is triggered by MouseEnter/MouseLeave events.
What I've found is that if I apply a new style for the parent control, which retemplates the hierarchy, sometimes the application will blow up giving this exception:
An unhandled exception of type 'System.InvalidOperationException' occurred in PresentationFramework.dll
Additional information: 'OuterBorderNormal' name cannot be found in the name scope of 'System.Windows.Controls.ControlTemplate'.
Any idea what I can do about this? It seems like when the template switches, perhaps it fires MouseLeave, thus firing my animation but it has already swapped out the template so my OuterBorderNormal control isn't found. That's my guess anyhow.
Here's the lowest portion of the call stack in case that helps:
> PresentationFramework.dll!System.Windows.Media.Animation.Storyboard.ResolveTargetName(string targetName = "OuterBorderNormal", System.Windows.Markup.INameScope nameScope, System.Windows.DependencyObject element) + 0x16b bytes
PresentationFramework.dll!System.Windows.Media.Animation.Storyboard.ClockTreeWalkRecursive(System.Windows.Media.Animation.Clock currentClock, System.Windows.DependencyObject containingObject, System.Windows.Markup.INameScope nameScope, string parentObjectName, System.Windows.PropertyPath parentPropertyPath, System.Windows.Media.Animation.HandoffBehavior handoffBehavior = SnapshotAndReplace, System.Collections.Specialized.HybridDictionary clockMappings = {System.Collections.Specialized.HybridDictionary}, long layer = 1) + 0x34e bytes
PresentationFramework.dll!System.Windows.Media.Animation.Storyboard.ClockTreeWalkRecursive(System.Windows.Media.Animation.Clock currentClock, System.Windows.DependencyObject containingObject = {ActiproSoftware.Windows.Controls.Ribbon.Controls.Group Items.Count:5}, System.Windows.Markup.INameScope nameScope = {System.Windows.Controls.ControlTemplate}, string parentObjectName, System.Windows.PropertyPath parentPropertyPath, System.Windows.Media.Animation.HandoffBehavior handoffBehavior = SnapshotAndReplace, System.Collections.Specialized.HybridDictionary clockMappings = {System.Collections.Specialized.HybridDictionary}, long layer = 1) + 0x2bd bytes
PresentationFramework.dll!System.Windows.Media.Animation.Storyboard.BeginCommon(System.Windows.DependencyObject containingObject = {ActiproSoftware.Windows.Controls.Ribbon.Controls.Group Items.Count:5}, System.Windows.Markup.INameScope nameScope, System.Windows.Media.Animation.HandoffBehavior handoffBehavior = SnapshotAndReplace, bool isControllable = true, long layer) + 0xaa bytes
PresentationFramework.dll!System.Windows.Media.Animation.BeginStoryboard.Begin(System.Windows.DependencyObject targetObject, System.Windows.Markup.INameScope nameScope, long layer) + 0x44 bytes
PresentationFramework.dll!System.Windows.Media.Animation.BeginStoryboard.Invoke(System.Windows.FrameworkElement fe, System.Windows.FrameworkContentElement fce, System.Windows.Style targetStyle, System.Windows.FrameworkTemplate frameworkTemplate, long layer) + 0x26 bytes
PresentationFramework.dll!System.Windows.StyleHelper.InvokeEventTriggerActions(System.Windows.FrameworkElement fe = {ActiproSoftware.Windows.Controls.Ribbon.Controls.Group Items.Count:5}, System.Windows.FrameworkContentElement fce = null, System.Windows.Style ownerStyle = null, System.Windows.FrameworkTemplate frameworkTemplate = {System.Windows.Controls.ControlTemplate}, int childIndex = 0, System.Windows.RoutedEvent Event) + 0x105 bytes
PresentationFramework.dll!System.Windows.StyleHelper.ExecuteEventTriggerActionsOnContainer(object sender, System.Windows.RoutedEventArgs e) + 0xd6 bytes
All replies
-
-
We are changing the issue type to “Comment” because you have not followed up with the necessary information. If you have more time to look at the issue and provide more information, please feel free to change the issue type back to “Question” by editing your initial post and changing the radio button at the top of the post editor window. If the issue is resolved, we will appreciate it if you can share the solution so that the answer can be found and used by other community members having similar questions.
Thank you!