我希望我的头衔清楚......
我的意思是我们定义动画时的例子:
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
就是应该添加到StoryBoard
的Children
财产?如果我需要做同样的事情,我需要申报什么?