加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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标签旁边添加一个图像.
如果你指导我会没事吗?

编辑:
图像是方法的输出.该方法使图像来自base-64字符串.

解决方法

只要你已经熟悉如何绑定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>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读