开发者

How to have image and button column in ListView in WPF

开发者 https://www.devze.com 2022-12-14 20:12 出处:网络
I have to add two开发者_开发技巧 columns in a ListView.One column shows different Images and another column is used to show a Button.

I have to add two开发者_开发技巧 columns in a ListView. One column shows different Images and another column is used to show a Button.

It will be great help if anybody provide the any link or example source code. Thanks in advance.


This would give you two columns one with a button one with an image. if i was doing it i would put a command on my item so i could bind my button to it.

  <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>

You would need to have an items source containing items that have a property called ImageSource

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号