自动生成的列后的WPF datagrid添加按钮 [英] WPF datagrid add button after autogenerated columns

查看:404
本文介绍了自动生成的列后的WPF datagrid添加按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个wpf应用程序,其中datagrid具有自动生成的列,我想在此列之后再添加两个包含按钮的地方,我尝试使用datagridtemplatecolumn和代码,但是什么也没有。有什么帮助吗?谢谢...

I have a wpf app, where a datagrid has autogeneratedcolumns, and I want after that columns add two more containing buttons, I've tried working with datagridtemplatecolumn and code, but nothing. Any help? Thanks...

<DataGridTemplateColumn>
   <DataGridTemplateColumn.CellTemplate>
     <DataTemplate>                                            
       <Button x:Name="btnEdit" Tag="{Binding Category}">Edit</Button>
     </DataTemplate>
   </DataGridTemplateColumn.CellTemplate>
 </DataGridTemplateColumn>


推荐答案

我已解决问题,谢谢!这是解决方案,以防万一...:)

I fixed the problem, thanks! Here is the solution, just in case... :)

<DataGrid.Columns>
 <DataGridTextColumn Visibility="Hidden"/>
 <DataGridTextColumn Header="Category" Binding="{Binding Category}" />
 <DataGridTemplateColumn Header="Birthday">
   <DataGridTemplateColumn.CellTemplate>
     <DataTemplate>
       <Button Content="Edit" />
     </DataTemplate>
   </DataGridTemplateColumn.CellTemplate>
 </DataGridTemplateColumn>

这篇关于自动生成的列后的WPF datagrid添加按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆