zl程序教程

您现在的位置是:首页 >  后端

当前栏目

WPF之ListView使用WrapPanel

WPF 使用 listview WrapPanel
2023-06-13 09:12:39 时间

大家好,又见面了,我是你们的朋友全栈君。

为了在ListView中显示Wrap样式的子项,需要设置ItemsPanel为WrapPanel,如下所示。此外,还要将ScrollViewer.HorizontalScrollBarVisibility设置为”Disabled”,否则是不能Wrap的。

实现的代码如下所示:

<ListView ItemsSource=”{Binding Source={StaticResource workCollectionView}}” ScrollViewer.HorizontalScrollBarVisibility=”Disabled”> <ListView.ItemTemplate> <DataTemplate> <Image MaxWidth=”100″ Source=”{Binding PicFilePath}”/> </DataTemplate> </ListView.ItemTemplate> <ListView.ItemsPanel> <ItemsPanelTemplate> <WrapPanel IsItemsHost=”True” Orientation=”Horizontal” /> </ItemsPanelTemplate> </ListView.ItemsPanel> </ListView>

发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/163309.html原文链接:https://javaforall.cn