We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

SfDataGrid-Column with Buttons

Thread ID:





131609 Jul 19,2017 12:02 PM UTC Jul 21,2017 03:56 AM UTC WPF 1
Tags: SfDataGrid
Harald Betzler
Asked On July 19, 2017 12:02 PM UTC


I've a list of data items with two properties (ItemName (string) and ItemFlag (boolean)). I want to have a SfDataGrid with two columns. 

A text column displaying the ItemName and a button column displaying a button (bound to a viewmodel command) if ItemFlag=true or displaying nothing (or a disabled button) if ItemFlag=false.

I think I'll need a DataTemplateSelector but in my trials the overridden SelectTemplate method was never called.

Can you help me?


Muthukumar Kalyanasundaram [Syncfusion]
Replied On July 21, 2017 03:47 AM UTC

Hi Harald, 
Thank you for contacting Syncfusion support. 
We have checked your query. You can pass the row information as a parameter to the command in ViewModel when clicking a button in TemplateColumn by passing the CommandParameter like the below code example,  
Code Snippet: 
    <syncfusion:GridTextColumn MappingName="Name" /> 
    <syncfusion:GridTemplateColumn MappingName="City" syncfusion:FocusManagerHelper.WantsKeyInput="True"> 
                <Button  Content="Click" syncfusion:FocusManagerHelper.FocusedElement="True"   
Command="{Binding Path=DataContext.RowDataCommand,ElementName=sfGrid}" CommandParameter="{Binding}"/> 
For your reference, we have attached sample and KB link. Could you please refer to it. 
Please let us know if you have any query. 
Muthukumar K 


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon