【发布时间】:2014-05-28 14:51:58
【问题描述】:
我有什么:
我的班级:
public class MyImage
{
public String ImagePath { get; private set; }
public String Name { get; private set; }
// ...
}
XAML:
<Window.Resources>
<DataTemplate x:Key="template_image">
<Image Source="{Binding Path=ImagePath}" Stretch="None" />
</DataTemplate>
<DataTemplate x:Key="template_name">
<TextBlock Text="{Binding Path=Name}" />
</DataTemplate>
</Window.Resources>
<ListView x:Name="gui_listview_graphics" Margin="75,0,0,0">
<ListView.View>
<GridView>
<GridViewColumn Header="Graphic" CellTemplate="{StaticResource template_image}" />
<GridViewColumn Header="Name" CellTemplate="{StaticResource template_name}" />
</GridView>
</ListView.View>
</ListView>
工作正常。
现在我想要什么..
我需要显示一个图像列表而不是一个图像。
我的新班级:
public class MyNewImage
{
public ObservableCollection<String> ImagePath { get; private set; }
public String Name { get; private set; }
// ...
}
DataTemplate 应该包含一个包含所有图像的 Stackpanel..
有可能吗?
如果是,如何..
谢谢!
【问题讨论】:
标签: c# wpf datatemplate celltemplate