c# – 像这样在WPF中向ListView添加图像……?
发布时间:2020-12-15 19:35:22 所属栏目:百科 来源:网络整理
导读:我将在 WPF中创建一个ListView,如下图所示 ListView in WPF http://www7.picfront.org/picture/ZcYGCAbgtG/thb/FF3-bookmark-manager.jpg http://www.picfront.org/d/7xuv 我的意思是我想在Name列中的Gravatar标签旁边添加一个图像. 如果你指导我会没事吗?
我将在
WPF中创建一个ListView,如下图所示
ListView in WPF http://www7.picfront.org/picture/ZcYGCAbgtG/thb/FF3-bookmark-manager.jpg http://www.picfront.org/d/7xuv 我的意思是我想在Name列中的Gravatar标签旁边添加一个图像. 如果你指导我会没事吗? 编辑: 解决方法
只要你已经熟悉如何绑定ListView数据,那么它真的非常简单.在您的单元格模板中,您只需要一个带有Image和TextBlock的StackPanel.
<ListView> <ListView.View> <GridView> <GridViewColumn> <GridViewColumn.CellTemplate> <DataTemplate> <StackPanel Orientation="Horizontal"> <Image Width="16" Height="16" Source="{Binding IconUri}"/> <TextBlock Text="{Binding Name}"/> </StackPanel> </DataTemplate> </GridViewColumn.CellTemplate> </GridViewColumn> <GridViewColumn ... /> <GridViewColumn ... /> </GridView> </ListView.View> </ListView> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |