I have two FieldLayouts in my XamDataGrid. These FieldLayouts use several converters to define colors of styles etc.
When I change the colors on run-time, I would like to update the colors in the XamDataGrid.
Is it possible to "refresh" the layouts, so that the converters are run again?
Hi Christian,
Here is a set of steps that should work:
This should cause all the elements to get re-hydrated.
Hello Joe
I'm not sure what you mean by ClearValue(TemplateProperty)!
My XamDataGrid has two fieldlayouts (master/nested), with different styling. What is the TemplateProperty are you are referring to?
You can leave it set to 'Virtualize'.
However, that mode is not as performant when scrolling new records into view. In virtualize mode element trees for records that are scrolled out of view will be discarded and new element trees for records that are scrolled into view will be hydrated.
This differs from 'Recycle' mode (which is the default mode) where the element trees of records that are scrolled out of view will be reused for the records that are being scrolled into view. This results in a much smoother scrolling experience.
Thanks for your reply!
I used the second method. Just one question. Is it correct that I need to set the "mode" to Virtualize first and then set it to Recycle, right after?
If I only use Virtualize the whole thing only work once...
You are correct, it doesn't work. My apologies for not trying this first. The reason is that we are caching the RecordListControl inside the data grid.
Here are 2 workarounds that I have tried that work:
1: Toggle the template of the RecordListControl inside the XamDataGrid (DG1)
RecordListControl rlc = Utilities.GetDescendantFromType<RecordListControl>(this.DG1, true, null);
ControlTemplate
template = rlc.Template;
rlc
.Template = null;
.Template = template;
or 2: Toggle the RecordContainerGenerationMode:
this
.DG1.RecordContainerGenerationMode = ItemContainerGenerationMode.Virtualize;
.DG1.RecordContainerGenerationMode = ItemContainerGenerationMode.Recycle;
I tried the above code and it didn't work for me.
The ItemsSource of my XamDataGrid is bound to a collection within an object. I could just try to "refresh" this collection, but this would keep the user waiting and might require a database-call.
In C# you would do this (assuming your instance of the XamDataGrid was named 'xamDataGrid1'):
this.xamDataGrid1.Template = null;
this.xamDataGrid1.UpdateLayout(); // This line is proabaly not necessary. I wouldn'use it unless it is.
this.xamDataGrid1.ClearValue(Control.TemplateProperty);