how to re-apply StyleSelector and TemplateSelector on GridViewRow

3 posts, 1 answers
  1. runer
    runer avatar
    5 posts
    Member since:
    May 2017

    Posted 20 Sep Link to this post

    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. Answer
    Martin Vatev
    Admin
    Martin Vatev avatar
    129 posts

    Posted 22 Sep Link to this post

    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 allow you to write beautiful native mobile apps using a single shared C# codebase.
  3. runer
    runer avatar
    5 posts
    Member since:
    May 2017

    Posted 25 Sep in reply to Martin Vatev Link to this post

    Thanks, it works.
Back to Top