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. Image for the cookie policy date

counting number of rows in DataGridControl

I need a way to hide the data grid control when there are no records. In the native WPF implementation it would be done like this:
DependencyObject obj = (DependencyObject)e.OriginalSource;
            if (obj is DataGrid)
                if ((obj as DataGrid).Items.Count == 0)
                    (obj as DataGrid).Visibility = Visibility.Collapsed;

however items is not a property on the WPF Data Grid Control. How can this be done? thanks

2 Replies

JL Joseph Lopez November 22, 2013 08:30 PM UTC

found it

if ((obj as Syncfusion.Windows.Controls.Grid.GridDataControl).Model.RowCount <= 1) //header is counted
                    (obj as Syncfusion.Windows.Controls.Grid.GridDataControl).Visibility = Visibility.Collapsed;

SM Saravanan M Syncfusion Team December 4, 2013 12:47 PM UTC

Hi Joseph,

Thanks for you update,

You can also get the Rowcount by applying below code snippet.


int count = this.syncgrid.Model.RowCount;


Please let us know if you have any queries,



Live Chat Icon For mobile
Up arrow icon