WPF-知识积累
(1)ListBox之子级内容显示。
<StackPanel> <UserControl ContentTemplate="{}" Content="{Binding SelectedItem,ElementName=listBoxCars}"/> <ListBox x:Name="listBoxCars" ItemTemplate="{}"> </StackPanel>
在content进行binding时,可以直接binding到listbox的SelectedItem之上。可以省去listbox的selectchanged事件的发生。
listbox的ItemsPanel,它的数据类型为ItemsPanelTemplate,是一种controlTemplate.如下代码则可以改变listbox的显示方向。
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
(2)Style
使用style时,如果value的值比较简单,那就直接用Attribute值来表示。
浙公网安备 33010602011771号