Silverlight/WPF parenthetical value syntax in a Storyboard animation
Somehow in my WPF studies, this detail has escaped me.
I've seen syntax of this sort:
<UserControl.Resources>
<Sto开发者_开发技巧ryboard x:Name="myStoryboard">
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" ... >
...
Why is the StoryBoard.TargetProperty value surrounded by parentheses? What does that mean? Clearly it means something, because my code doesn't work without it.
This is the syntax for binding to an attached property on a class: (Class.Property)
You can read more about Dependency Properties and Attached Properties here.
From MSDN:
This syntax is generally used for one of the following cases:
- The path is specified in XAML that is in a style or template that does not have a specified Target Type. A qualified usage is generally not
valid for cases other than this,
because in non-style, non-template
cases, the property exists on an
instance, not a type.- The property is an attached property.
- You are binding to a static property.
For use as storyboard target, the property specified as propertyName must be a DependencyProperty.
精彩评论