Solved

WPF Datagrid Button

Posted on 2011-03-23
2
569 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
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
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…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

708 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now