
上QQ阅读APP看书,第一时间看更新
Collection syntax
Sometimes it's required to define a collection of elements in the XAML. This is done using the Collection syntax to make it more readable. For example, a StackPanel can have multiple elements defined inside the Children property :
<StackPanel> <StackPanel.Children> <Button Content="1" /> <Button Content="2" /> </StackPanel.Children> </StackPanel>
The preceding example can also be written as follows, where the parser knows how to create and assign it:
<StackPanel> <Button Content="1" /> <Button Content="2" /> </StackPanel>