我希望我的標題是明確....在設置XAML中元素的內容時,WPF如何確定要設置的屬性?
我的意思是〔實施例當我們定義動畫:
的XAML:
<StoryBoard>
<DoubleAnimation..../>
</StoryBoard>
但是,如果我們定義了同樣的事情的代碼隱藏我們可以這樣做:
DoubleAnimation myDAnimation = new DoubleAnimation();
.....
StoryBoard myStoryBoard = new StoryBoard();
myStoryBoard.Children.Add(myDAnimation);
我試圖尋找到故事板的類定義,沒有什麼特別的:
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; }
....
}
我知道,如果我定義我自己的類與上述sytnax,爲了加入到我的孩子,我需要:
XAML:
<MyClass>
<MyClass.Children>
<MyClassCildrenItem..../>
</MyClass.Children>
</MyClass>
因此,如何在XAML中知道DoubleAnimation
是應該添加到StoryBoard
的Children
屬性? 如果我需要做同樣的事情,我需要申報什麼?
啊,謝謝,我明白了。我一直認爲這是構造函數。不知道這是屬性......這就是爲什麼這些Button等控件我可以簡單地在他們的定義中定義另一個控件。 +1(需要3分鐘再接受答案...) – 2012-03-18 19:47:45