因此,我已绑定一个列表
到的ListView
其中列表
的类型是专辑
,它有很多特性,包括设备罩起来
,我是一个的项目图像在磁盘上。嗯,因为我不知道是什么类型的图像是必要的,它们是如何被加载(我只知道用图片类型的WinForms),我不知道类型呢。
有人可以显示或张贴我一个快速的样品,其中就说明这类物品被显示为用他们的设备罩起来
属性某一固定大小的图像?
在本质上,这将显示:
在什么类型的设备罩起来
应
如何从磁盘WPF打开图像(假设它比的WinForms图像加载不同)
如何向他们展示在一个ListView作为某些固定大小的图片,缩放图像如有必要
解决方案
的ImageSource
的ImageSource myImageSource =新的BitmapImage(新的URI(@文件:// C:... something.jpg));
指定的ListView的ItemTemplate属性的项目的数据模板:
< Window.Resources>
< DataTemplate中X:关键=ItemTemplate中>
< StackPanel的方向=横向>
<图像宽度=10高度=10弹力=填充来源={装订封面}/>
<标签内容={结合标题}/>
< / StackPanel的>
< / DataTemplate中>
< /Window.Resources>
<电网X:名称=网格>
< ListView控件的ItemTemplate ={的StaticResource的ItemTemplate}的ItemsSource ={结合相册}/>
< /网格>
So I have binded a List
to a ListView
where the List
has items of type Album
, where it has lots of properties including .Cover
, which I is an image on disk. Well since I don't know what type of image is needed and how they have to be loaded (I only know using Image types for Winforms), I don't know the type yet.
Can someone show or post me a quick sample where it shows this sort of items being shown as images of a certain fixed size using their .Cover
property?
In essence this would show:
What type.Cover
should be
How to open images from disk for WPF (assuming it's different than Winforms image loading)
How to show them on a ListView as images of a certain fixed size, scaling the images if necessary
解决方案 ImageSource ImageSource myImageSource = new BitmapImage(new Uri(@"file://C:... something.jpg"));
Specify a data template for the items in the ListView's ItemTemplate property:
<Window.Resources>
<DataTemplate x:Key="ItemTemplate">
<StackPanel Orientation="Horizontal">
<Image Width="10" Height="10" Stretch="Fill" Source="{Binding Cover}"/>
<Label Content="{Binding Title}" />
</StackPanel>
</DataTemplate>
</Window.Resources>
<Grid x:Name="grid">
<ListView ItemTemplate="{StaticResource ItemTemplate}" ItemsSource="{Binding Albums}" />
</Grid>
相关推荐
最新文章