1
下面的两种语法都适用。我的问题是WPF如何知道内容是我指定的?内容属性如何工作
<Button>
<Button.Content>
my button
</Button.Content>
</Button>
<Button>
my button <!--how does wpf know this is the content-->
</Button>
同样,如何WPF知道现在我加入ListBoxItems
<ListBox>
<!--ListBox.Items-->
<ListBoxItem Content="item 1" /> <!--XAML automatically knows I'm specifying items-->
item 2
<ListBoxItem Content="item 3" />
<!--/ListBox.Items-->
</ListBox>
所以在ContentControl中,默认的属性就是内容,并与ItemsControl的,默认的是项目,并与文本框,在默认是TextBox。
这个'默认'是如何工作的?
当我创建自定义控件时,如何创建此“默认属性”?