Hi,
In my scenario i do not want virtualization on and hence I have switched it off by wrapping grid in scrollviewer, the performance is good when i am scrolling but the moment I add conditional formatting (via code behind) i see the scrolling is very slow. I used JetBrains dotTrace and windbg and can see the grid is recycling cells (See attached symbol). Can you please explain why this is so, the reason i turned off virtualization is because i have limited number of data rows (around 2000) and i do not want virtualization enabled.
Hello Rohit,
I have contacted our development team about more information on this matter and they will do the best to modify the reported behavior for our upcoming Service Release.
Thank you for understanding.
>> If the ‘ShouldRefreshOnDataChange’ property is set to “true”, it makes the rule to be reapplied if the data is changed and this makes the delay in your scenario.
I am sorry but i think this is pretty obvious from the sample that i created, there is nothing new you are telling me here.
I cannot go and explain this to my business users (around 150+ around the globe) that as vendor library repaints all the cells + spikes CPU, we cannot refresh the cells, it is better if i hand over my resignation letter to them. I cannot explain but believe me conditional formatting is very important in my scenarios so cells could stand out.
I used xamgrid as it was developed for performance out of the box, and if i cannot apply a style to a new row without spiking up cpu then xamgrid is of no use to me.
I very well comprehend and understand that this is a limitation and not currently supported, all i am asking for is to know how long would it take to get it fixed so that if needed i can swtich to other vendors. So my question is to know if the developement team is anytime going to work on this or should i evaluate other vendors? personally this is a basic feature and i cannot push you enough to have it, appreciate honest comments.
Thanks so much,
Rohit
Hello,
As is obivous from my sample I can understand that xamgrid refreshes all cells. The added row sample was just to show you that CPU spikes up when a new row is added. This is not the production code.
In my case the style is not only applied just when the row is added/initialized (this was just a sample to show that xamgrid refreshes all cells) but when some calculation is done on the particular row cell value which causes other cell value to change and that is when i want the style to be applied on that cell and or rows, apparently I have around 4 columns and depending on the state machine each such cell shows a different background color (gradient color depending on some financial calculation)(, I cannot put if and buts code every where in my code just so i could apply styling, best would be if i could define style and get it applied appropriately without spiking up the cpu.
Would it be possible to patch the performance issue in the next service release? or by creating a new refresh methodology?
Thanks
The conditional formatting rules are applied over a column either by a row (i.e. the whole column layout) or a cell (i.e. only the column cells). Setting ShouldRefreshOnDataChange to true means that the rule(s) will be reapplyed over the column layout cells after changing the data source. You could achieve styling only the added row by handling the CollectionChanged event of the data source of the grid and applying the desired style to the new row. Here is a sample code:bool isInitialized = false;public MainWindow(){ ..... Source = new ObservableCollection<Data>(); this.Source.CollectionChanged += Source_CollectionChanged; Source.Add(....) isInitialized = true; }void Source_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e){ if (isInitialized && e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add) { Style s = new System.Windows.Style(); s.Setters.Add(new Setter() { Property = CellControl.BackgroundProperty, Value = new SolidColorBrush(Colors.Yellow) }); Grid1.Rows[Grid1.Rows.Count - 1].CellStyle = s; }}Note that the grid property IsAlternateRowsEnabled should be "False" so the added style could be applied to every row.
I have logged this behavior with our developers in our tracking system, with an issue ID of 152229. I have also created a support ticket on your behalf with number CAS-122402-N5N4Q0 in order to link the development issue to it so that you are automatically updated when a Service Release containing your fix is available for download.