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

What is the best way to refresh sfDataGrid UI?

Thread ID:





133041 Oct 5,2017 01:31 PM UTC Oct 9,2017 11:35 AM UTC Xamarin.Forms 3
Tags: SfDataGrid
Gunnar Carlson
Asked On October 5, 2017 01:31 PM UTC

From a performance point of view - what is the best way to refresh a grid on the display?

I have en app where the user can select different skins and the skinning of the datagrid is implemented on both grid and cell levels:

grid (for headers and gridlines):

GridStyle="{StaticResource gridColors}"


    <Style TargetType="syncfusion:GridCell">
        <Setter Property="Foreground"
            Value="{Binding UserData[0].TextColor, Mode=OneWay}" />
        <Setter Property="BackgroundColor"
            Value="{Binding UserData[0].BackgroundColor, Mode=OneWay}" />

All of this works exactly as I want it to, no problem. But when a user select a new skin, I need to initiate a refresh of the complete grid to apply the new skin, and the only way I have found to do this is through:

dataGrid.ItemsSource = null;
dataGrid.ItemsSource = data.Items;

This also do exactly what I want it to do, but the performance is rather poor.  Is there any better way to initiate a refresh of the grid style? (The content of the grid is unchanged, only the style is changed)

Ashok N [Syncfusion]
Replied On October 6, 2017 12:56 PM UTC

Hi Gunnar, 
Thanks for contacting Syncfusion support. 
We have checked your query and you can refresh the view by using DataRowBase.UpdateRow methods. Please refer the below code example  
private void Button_Clicked(object sender, EventArgs e) 
    var items = dataGrid.GetRowGenerator().Items; 
    foreach (var item in items) 

Gunnar Carlson
Replied On October 6, 2017 10:21 PM UTC

I tried the method you suggested and it doesn't do anything visible. Maybe the UpdateRow method tries to update the data content on the row, but since the content isn't changed, no visible change is made when the method is called. The only things that should be updated is the styling, and I can't see that UpdateRow do that.

BUT...I have found a solution through a tip you gave in one of my other questions.

Since a row in my case is an array of the class UserData, all I had to do was to raise a PropertyChanged event for "UserData"

foreach (var item in data.Items)
dataGrid.GridStyle = new GridColors();

The last line is to trigger an update of GridStyle (I have a gridstyle class defining some of the colors.)

With those two additions, I can make the datagrid apply the new skin much faster than when i re-bound the ItemSource. Problem solved.

Vimal Prabhu Manohkaran [Syncfusion]
Replied On October 9, 2017 11:35 AM UTC

Hi Gunnar,

Thanks for the update. Since you are using CellStyles for the GridCell, the approach you have mentioned above is the recommended and efficient approach. So we recommend you to stick on to the same.

Vimal Prabhu


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