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

Row Data Bound

Thread ID:





119565 Jul 9,2015 12:40 PM UTC Jul 10,2015 11:33 AM UTC WPF 1
Tags: SfDataGrid
saglietto piermaria
Asked On July 9, 2015 12:40 PM UTC

I have a grid with a TemplateColumn inside where there are various buttons. I need to manage the bind of each row and to show or hide buttons by row.
What is the of row data bound? Once I handled the event, how do I take the cell with the buttons and hide / view them?

Thanks in advance

Best regards

Gobikrishnan Murugesan [Syncfusion]
Replied On July 10, 2015 11:33 AM UTC


Thank you for contacting Syncfusion support.

We have analyzed your Query. The requirement “Show/hide buttons in template column based on row data” can be achieved in two ways. Please find the details below,

Using IValueConverter
While loading the grid, you can show/hide buttons by using IValueConverter.


        <syncfusion:SfDataGrid x:Name="grid"

                        ItemsSource="{Binding student}" Grid.Row="0" Grid.RowSpan="2" AutoGenerateColumns="False"

                        ShowGroupDropArea="True" AllowGrouping="True"



                <syncfusion:GridTextColumn   HeaderText="Name" MappingName="Name"  />

                <syncfusion:GridTextColumn    HeaderText="Age"  MappingName="Age" />

                <syncfusion:GridCurrencyColumn AllowScrollingOnCircle="False" CurrencyDecimalDigits="2" CurrencyPositivePattern="2" CurrencySymbol="$" HeaderText="Income" MappingName="Income" />

                <syncfusion:GridCheckBoxColumn MappingName="IsCheck" HeaderText="Registered" />

                <syncfusion:GridTemplateColumn HeaderText="Template Column" MappingName="Name">



                            <Button VerticalAlignment="Center" Height="25" Width=" 65"



                                                            Content="{Binding Quantity}"

                                                            Visibility="{Binding Converter={StaticResource converter}}"








class Converters :IValueConverter


        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)


            var values =(Student) value;

            if (values.Age == 12)

                return Visibility.Visible;

            return Visibility.Hidden;


        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)


            throw new NotImplementedException();



Using Current cell activated event
Using CurrentCellActivated event, you can change the button visibility based on row data while clicking the grid cell at run time.


public UserControl1()





private void grid_CurrentCellActivated(object sender, CurrentCellActivatedEventArgs args)


    //get the current cell

    var currentcell = grid.SelectionController.CurrentCellManager.CurrentCell.ColumnElement;

    // search the button using Visual tree

    Button button = GetVisualChild<Button>(currentcell);

    //current cell row data

    var rowdata = (Student)currentcell.DataContext;

    //based on the data button visibility has been decided

    if (rowdata.Age != 12 && button!=null)

        button.Visibility = Visibility.Visible;     


We have also prepared the sample based on this and please find the sample under the following location

If your requirement is differ from this, could you please share more information on your requirement. This would be helpful for providing better solution.

Please let me know if this solution helps you.


Gobikrishnan M


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

or the page will be automatically redirected to 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