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

Background colors of cells missed

1 Answer 45 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Fernando
Top achievements
Rank 1
Fernando asked on 01 Oct 2014, 11:44 AM
Hello,

I have a simple application containing a RadGridView with the ItemsSource binded to an ObservableCollection of elements. I use the RowLoaded event to set the background of the cells and it works fine.
Here is the code i use in the RowLoaded:
            string colorStr = "#5cfc56";
            SolidColorBrush b = new SolidColorBrush();
            b.Color = (Color)ColorConverter.ConvertFromString(colorStr);
            var cell= (from a in e.Row.Cells where a.Column.UniqueName == "a" select a).FirstOrDefault();
            cell.Background = b;
            cell.ToolTip = "aaaas";

The problem is that when i refresh the ObservableCollection with new elements the grid does not apply the background color to the rows in spite of launching the RowLoadedEvent however the Tooltip of the cell works.

Is there something i'm doing wrong here?


Tanks.







1 Answer, 1 is accepted

Sort by
0
Accepted
Yoan
Telerik team
answered on 01 Oct 2014, 05:55 PM
Hello,

This is the expected behaviour when GridView's Virtualization is enabled. When the virtualization of RadGridView is turned on, its elements are created when they should be brought into view and they are also reused on scrolling (i.e. the rows/cells are recreated on scrolling). Thus, it is not recommended to work with the visual elements (i.e. GridViewRow/GridViewCell) and their properties. You can take a look at the UI Virtualization help article for a reference. The better approach is to work with the data items. Please check the RowStyleSelector and CellStyleSelector help articles for a reference.

Regards,
Yoan
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
GridView
Asked by
Fernando
Top achievements
Rank 1
Answers by
Yoan
Telerik team
Share this question
or