相关疑难解决方法(0)

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财产?如果我需要做同样的事情,我需要申报什么?

c# silverlight wpf xaml

2
推荐指数
1
解决办法
1142
查看次数

标签 统计

c# ×1

silverlight ×1

wpf ×1

xaml ×1