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.
Alright, after burning a lot of blood I found the issue is because of "ShouldRefreshOnDataChange" property
http://help.infragistics.com/Help/NetAdvantage/WPF/2012.1/CLR4.0/html/InfragisticsWPF4.Controls.Grids.XamGrid.v12.1~Infragistics.Controls.Grids.ConditionalFormattingRuleBase~ShouldRefreshOnDataChange.html
I have created another sample for you/devs. Please give it a go and let me know if it is a bug or not (I hope it is not by design as performance is not acceptable at all).
Summary:
If we set "ShouldRefreshOnDataChange" to false, and if add a new row to the grid the cpu takes only 3-4% on my box.
If we set "ShouldRefreshOnDataChange" to true, and add a new row, the cpu takes 25% (i.e. one full core)
Try running the attached sample by turning on/off the above property in (TabItem1.xaml.cs) line 51
Per your documentation "ShouldRefreshOnDataChange - Get / set whether this rule needs to reaquire data due to cell value being changed", so it should render only the cell/row which is updated, but apparently as per the trace i see all cells are being repainted in the view port.
Could you please take this urgently with devs and update me if it is a bug and if so when it can be patched? We need conditional formatting, otherwise can you please let me know if there is any other way i can style a row manually when a particular property changes?
Attaching trace
I have been looking into your issue and by default disabling the virtualization of the XamGrid is at your own risk. In your scenario the loaded data is very large(25 columns x 1000 rows). This generates 25000 cells elements on loading the XamGrid. My suggestion is to enable the virtualization in your scenario.
Let me know, if you have any other questions on this matter.
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.
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,
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.