<ItemsControl Margin="10"
ItemsSource="{Binding Source={StaticResource myTodoList}}">
<!--The ItemsControl has no default visual appearance.
Use the Template property to specify a ControlTemplate to define
the appearance of an ItemsControl. The ItemsPresenter uses the specified
ItemsPanelTemplate (see below) to layout the items. If an
ItemsPanelTemplate is not specified, the default is used. (For ItemsControl,
the default is an ItemsPanelTemplate that specifies a StackPanel.-->
<ItemsControl.Template>
<ControlTemplate TargetType="ItemsControl">
<Border BorderBrush="Aqua" BorderThickness="1" CornerRadius="15">
<ItemsPresenter/>
</Border>
</ControlTemplate>
</ItemsControl.Template>
<!--Use the ItemsPanel property to specify an ItemsPanelTemplat
ControlTemplate in WPF —— ItemsControl
最新推荐文章于 2024-02-05 16:52:53 发布
本文详细介绍了WPF中ItemsControl的使用,包括如何通过ControlTemplate定义其外观,利用ItemsPanelTemplate控制布局,DataTemplate展示数据对象,以及ItemContainerStyle设置项容器样式。示例展示了如何创建一个具有边框、包裹布局和自定义数据可视化的待办事项列表。
摘要由CSDN通过智能技术生成