如何模拟WPF中ListView
的平铺视图?WPF中ListView的平铺视图
我试图here所示的例子。但我无法得到正确的解决方案...但我不想使用该解决方案,因为我的这是太具体。那么如何实现这一目标呢?
编辑:现在我想这一点,似乎工作...
<ListBox ItemsSource="{Binding Path=ListObservableUsers, ElementName=AdminWindow}">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Vertical">
<Image Source="{Binding Path=Picture}"></Image>
<Label Content="{Binding Path=Dni}"></Label>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
凡ElementName=AdminWindow
来自<Window .... x:Name="AdminWindow"
我创建了自己的ObservableCollection<MyUser>
public class MyUser
{
public MyUser(int id, string dni, Bitmap picture)
{
Id = id;
Dni = dni;
Image img = new Image();
FPhiMultipleSources.FromBitmapImage(img, picture);
Picture = img.Source;
}
public int Id { get; set; }
public string Dni { get; set; }
public ImageSource Picture { get; set; }
}
...
public UCAdminMain()
public UCAdminMain()
{
ListObservableUsers = new ObservableCollection<MyUser>();
InitializeComponent();
uiCurrent = SynchronizationContext.Current;
// Create users to add with its image
....
ListObservableUsers.Add(...);
}
现在我试图把它们放在包装面板中。现在没有运气......任何想法?
那是不够的......我们不会给你你的问题,顺便说一句,我们真的不知道一个完整的解决方案。向我们展示您尝试过的内容,不能在一个小的可编译代码示例中工作,我们试图帮助您并指出您朝着正确的方向发展。 – dowhilefor
问题是我不想使用该代码,因为我认为它有点具体......我需要知道改变它的通用方法。 – Sonhja
具体到底是什么? WPF的美妙之处在于我知道的任何框架,这在使用和外观上很容易修改。如何从该代码开始,因为使用ListView和使用TileView是开始进行自己的调整。例如,我们在我们的应用程序中使用它,并取得了很好的结果。 – dowhilefor