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.
similarly when i update the underlying data property, i see the below function slows down the UI phenomenally. As i mentioned there is no virtualization, the view port is very small, around 2000 rows and only 30 rows are visible with 10 columns. The performance etc is great when conditional formatting is not enabled, it works like a charm, but the moment i enable conditional formatting the whole grid struggles.
I see in the below stack trace, it is compiling dynamic delegate which is slowing down, is there any work around to improve the performance. The reason we choose xamgrid was because we expected performance would be better but this is not the case.
Appreciate your help.
THanks,
Rohit
Hello Rohit,
I have been looking into your issue and when enabling conditional formatting in the XamGrid positioned in a ScrollViewer, the scrolling works fine on my side. I am attaching a sample application() that I used for my tests. Could you please try the sample on your side and modify it if needed ? Also could you please tell me the version of our assembly files that you use like 11.2.20112.2316
Looking forward to hearing from you.
I am sorry but did you look at my last example? Please ignore all my above samples if not, just look at the last example i gave.
(1) Virtualization is ON in the sample.
(2) Performance is good when conditional formatting refresh is on (as described above)
(3) Performance is horrendous when i switch off the conditional formatting flag to false.
Sorry performance is good when refreshoncacheupdate on conditional formatting is off, but when it is turned on performance is really bad. This has nothing to do with the subject line and possibly virtualization as i have enabled virtualization in the sample.
Hello,
Any updates on the issue? Did you try my last example?
Hi Rohit,
I have been looking into your concerns and if the ‘ShouldRefreshOnDataChange’ property is set to “True” makes the corresponding conditional formatting to be reapplied on all the cells, not only on the last modified. This is the design behavior of the control.
Let me know, if you need any further assistance on this matter.
I am sorry, but as per the documentation this is to be applied per row not "rows" across the grid.
So you are saying - If i have 2000 rows on my grid and row level conditional formatting is applied, and I add one row, we are going to repaint all rows/cells across the grid? If i am adding one row why are other row's cell style is being re-applied? Seriously, does it sound right to you? Because of this the entire core is maxed out when i add just one row.
Could you please double check this behavior with your development team. This sounds more like a design issue/bug to me rather "by design" behavior.
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,
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.