【发布时间】:2015-08-21 13:54:34
【问题描述】:
我是 WPF 新手,作为一个学习项目,我选择了像文件管理器这样的 Windows 资源管理器。在这个项目中,我想将列表视图显示为遵循流布局模式的图标列表。我尝试了这里给出的解决方案:WPF: ListView with icons view?。但他们让我的图标相互重叠。我的图标基本上是动态加载的用户控件。这是代表列表视图图标的用户控件代码:
<UserControl x:Class="MVCP.FileItem"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d" Height="156.767" Width="161.279">
<Grid HorizontalAlignment="Center">
<Image HorizontalAlignment="Center" Height="100" Margin="10,10,10,0" VerticalAlignment="Top" Width="141" Source="fileflat.png"/>
<TextBlock HorizontalAlignment="Center" Margin="10,120,10,5" TextWrapping="Wrap" Text="<Filename>" VerticalAlignment="Center" Height="32" Width="141" FontSize="18" Foreground="White" TextAlignment="Center"/>
</Grid>
</UserControl>
这是我的 ListView 代码:
<ListView x:Name="files" Background="#FF19174B" AllowDrop="True" ScrollViewer.HorizontalScrollBarVisibility="Disabled" PreviewMouseLeftButtonDown="files_PreviewMouseLeftButtonDown" MouseMove="files_MouseMove">
<local:FileItem/>
<local:FileItem/>
<local:FileItem/>
<local:FileItem/>
</ListView>
如何排列这些用户控件,使它们看起来像 Windows 资源管理器图标?
【问题讨论】:
-
您是否尝试过在
ListView中使用面板? -
谢谢@AbinMathew,你给了我一个提示,我试了一下。有效。看我的回答。 :)