This is a migrated thread and some comments may be shown as answers.

how to re-apply StyleSelector and TemplateSelector on GridViewRow

2 Answers 223 Views
GridView
This is a migrated thread and some comments may be shown as answers.
runer
Top achievements
Rank 1
runer asked on 20 Sep 2017, 06:29 AM

I have some columns with `CellStyleSelector` and `CellTemplateSelector` which associating with a property in row data, when the property changed in code behide, both StyleSelector and TemplateSelector are not refreshed.

now I have got the row which need to refresh from `ItemContainerGenerator`, but have no idea to do that.

RadGridView.Rebind() works but it might be a little heavy.

public void RefreshRowTheme(object rowData)
{
    var container = this.grid.ItemContainerGenerator.ContainerFromItem(rowData);
    if (container != null)
    {
        var row = container as GridViewRow;
        if (row != null)
        {
            //how to re-apply StyleSelector and TemplateSelector on all cells
        }
    }
}

 

Thanks.

2 Answers, 1 is accepted

Sort by
0
Accepted
Martin
Telerik team
answered on 22 Sep 2017, 02:36 PM
Hi,

Generally, every time when the property bound to the column (with the CellTemplateSelector or CellStyleSelector) changes, the CellTemplateSelector/CellStyleSelector should be re-evaluated. The recommended way to do this re-applying of the selectors is to fire PropertyChanged event of your bound property. Also, working with the visual elements of RadGridView is not recommended approach because of virtualization character of the control. Can you please clarify wheater such PropertyChanged notification is raised?

Regards,
Martin Vatev
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which you to write beautiful native mobile apps using a single shared C# codebase.
0
runer
Top achievements
Rank 1
answered on 25 Sep 2017, 09:36 AM
Thanks, it works.
Tags
GridView
Asked by
runer
Top achievements
Rank 1
Answers by
Martin
Telerik team
runer
Top achievements
Rank 1
Share this question
or