?
Solved

WPF Datagrid Button

Posted on 2011-03-23
2
Medium Priority
?
585 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 2000 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

More Than Just A Video Library

Train for your certification. Learn the latest DevOps tools. Grow your skillset to do better work.

At Linux Academy, we release new training modules every week so you'll always be up to date on the latest tech.

Question has a verified solution.

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

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

762 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