Controls
控件只是数据和行为的载体是个抽象的概念,至于它本身会长成什么样子(控件内部结构)、
它的数据长成什么样子(数据显示结构)都是靠Template生成的。
决定控件外观的ControlTemplate,决定数据外观的是DataTemplate,
它们正是Control类的Template和ContentTemplate两个属性的值。
作用范围:
ControlTemplate 控件本身(包括内容区域)
DataTemplate 内容区域
案例1:ListBox的Item改成横向显示
<ListBox>
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<TextBlock Text="Allan"/>
<TextBlock Text="Kevin"/>
<TextBlock Text="Drew"/>
<TextBlock Text="Timothy"/>
</ListBox>
ps:https://fontawesome.com/ C#图标库