WPF如何确定在XAML中设置元素内容时要设置的属性?

Kin*_*han 2 c# silverlight wpf xaml

我希望我的头衔清楚......

我的意思是我们定义动画时的例子:

XAML:

<StoryBoard>
    <DoubleAnimation..../>
</StoryBoard>
Run Code Online (Sandbox Code Playgroud)

但是如果我们在代码隐藏中定义相同的东西,我们可以这样做:

DoubleAnimation myDAnimation = new DoubleAnimation();
.....
StoryBoard myStoryBoard = new StoryBoard();
myStoryBoard.Children.Add(myDAnimation);
Run Code Online (Sandbox Code Playgroud)

我试着看看StoryBoard的类定义,没什么特别的:

public sealed class Storyboard : Timeline
{
        public Storyboard();

        // Summary:
        //     Gets the collection of child System.Windows.Media.Animation.Timeline objects.
        //
        // Returns:
        //     The collection of child System.Windows.Media.Animation.Timeline objects.
        //     The default is an empty collection.
        public TimelineCollection Children { get; }
....
}
Run Code Online (Sandbox Code Playgroud)

我知道如果我用上面的sytnax定义我自己的类,为了添加到我的孩子中,我需要:

XAML:

<MyClass>
   <MyClass.Children>
      <MyClassCildrenItem..../>
   </MyClass.Children>
</MyClass>
Run Code Online (Sandbox Code Playgroud)

因此,如何在XAML中知道DoubleAnimation就是应该添加到StoryBoardChildren财产?如果我需要做同样的事情,我需要申报什么?

H.B*_*.B. 5

有一个属性: ContentPropertyAttribute

如果您检查SyntaxMSDN上的类部分,您可以看到在指定内容时将设置哪些属性.例如,ContentControl目标是Content财产.