Exception of Storyboard in controlTemplate,can't use binding or dynamic resource

msdn:

http://msdn.microsoft.com/en-us/library/ms742868.aspx

  • The TargeName may only refer to child objects of the ControlTemplate. If TargeName  is not specified, the animation targets the element to which the ControlTemplate is applied.

  • The SourceName for an EventTrigger or a Trigger may only refer to child objects of the ControlTemplate.

  • You can't use dynamic resource references or data binding expressions to set Storyboard  or animation property values. That's because everything inside a ControlTemplatemust be thread-safe, and the timing system must Freeze Storyboard  objects to make them thread-safe. A Storyboard cannot be frozen if it or its child timelines contain dynamic resource references or data binding expressions.

  • In XAML, you can't declare event handlers for Storyboard or animation events.

原文地址:https://www.cnblogs.com/liangouyang/p/1336394.html