views:

32

answers:

2

Somehow in my WPF studies, this detail has escaped me.

I've seen syntax of this sort:

<UserControl.Resources>
    <Storyboard 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.

+1  A: 

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.

Yacoder
A: 

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.

Islam Ibrahim