Solved

WPF Datagrid Button

Posted on 2011-03-23
2
582 Views
Last Modified: 2012-05-11
I have added a button to a data grid like below but how do I handle the click event?

  <DataGridTemplateColumn>
                                <DataGridTemplateColumn.CellTemplate>
                                        <DataTemplate>
                                        <Button Content="Edit" Name="btnEdit" >                                           
                                        </Button>
                                        </DataTemplate>
                                 </DataGridTemplateColumn.CellTemplate>
                            </DataGridTemplateColumn>
0
Comment
Question by:Kevin Robinson
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 16

Accepted Solution

by:
Imran Javed Zia earned 500 total points
ID: 35197092
Hi, you can either use RowCommand event and pass the CommandName in button as
<DataGridTemplateColumn>
                                <DataGridTemplateColumn.CellTemplate>
                                        <DataTemplate>
                                        <Button Content="Edit" Name="btnEdit" CommandName="Edit">                                          
                                        </Button>
                                        </DataTemplate>
                                 </DataGridTemplateColumn.CellTemplate>
                            </DataGridTemplateColumn>
Or you can uas add event Handler directly as
<DataGridTemplateColumn>
                                <DataGridTemplateColumn.CellTemplate>
                                        <DataTemplate>
                                        <Button Content="Edit" Name="btnEdit" OnClick="btnEdit_click" >                                           
                                        </Button>
                                        </DataTemplate>
                                 </DataGridTemplateColumn.CellTemplate>
                            </DataGridTemplateColumn>
0
 
LVL 3

Author Comment

by:Kevin Robinson
ID: 35197239
OK got that.. How do I then get the value (item) of the row.

0

Featured Post

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question