【问题标题】:How to have image and button column in ListView in WPF如何在 WPF 的 ListView 中有图像和按钮列
【发布时间】:2010-12-27 22:22:54
【问题描述】:

我必须在ListView 中添加两列。一列显示不同的Images,另一列用于显示Button

如果有人提供任何链接或示例源代码,这将是很大的帮助。 提前致谢。

【问题讨论】:

    标签: wpf image listview button wpf-controls


    【解决方案1】:

    这将为您提供两列,一列带有按钮,一列带有图像。如果我这样做,我会在我的项目上放一个命令,这样我就可以将我的按钮绑定到它。

      <ListView
         Name="myListView">
         <ListView.View>
            <GridView>
                <GridViewColumn>
                  <GridViewColumn.CellTemplate>
                     <DataTemplate>
                        <Button
                           Content="Click Me"
                           Margin="0"
                           VerticalAlignment="Center"
                           Click="Button_Click" />
                     </DataTemplate>
                  </GridViewColumn.CellTemplate>
               </GridViewColumn>
    
               <GridViewColumn>
                  <GridViewColumn.CellTemplate>
                     <DataTemplate>
                        <Image
                           Source="{Binding ImageSource}" />
                     </DataTemplate>
                  </GridViewColumn.CellTemplate>
               </GridViewColumn>
            </GridView>
         </ListView.View>
      </ListView>
    

    您需要有一个项目源,其中包含具有名为 ImageSource 的属性的项目

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-02-11
      • 1970-01-01
      • 1970-01-01
      • 2013-03-17
      • 2016-07-10
      • 2011-02-13
      • 2017-10-08
      相关资源
      最近更新 更多