Basic Information:Here is some information on setting some basic persistence settings on the xamGrid. If you have additional info that would be useful please add to this discussion.
References (Developer Guide-> Infragistics Control Persistence Framework):http://help.infragistics.com/Doc/Silverlight/2011.2/CLR4.0/Out of the box the persistence framework is extremely useful and saved us from countless hours of work and design. The settings are serialized to xml and easily compatible with streams. You can save and load settings from single or multiple controls into a settings group. You can easily reset settings to a default control state, or some other control state. After testing this it also works now with dynamic objects and dynamic data sources (meaning I can clear my settings and load new data or a new data source into a grid and save or load new persistence settings for the grid). There are also some good examples in the online documentation on how to get started.
Determining Which Properties to Save
It will automatically save/load all properties of the control or only the ones you specify. This really helps when you need to be concious of space and only need a handful of settings loaded or saved.
To give you an idea on the size comparison, here is the result using a grid with 5 columns:All Grid Properties: 933 KBOnly Specified: 11kb (1 property)XAML for specifying some settings and properties is listed below:
<ig:XamGrid><ig:PersistenceManager.Settings><ig:PersistenceSettings SavePersistenceOptions="OnlySpecified" LoadPersistenceOptions="AllButIgnored">
<ig:PropertyNamePersistenceInfo PropertyName="ColumnResizingSettings"/>
Its really that simple to setup. To save or load its even easier:Save persistence settings for a datagrid:
using System.IO;using Infragistics.Persistence;MemoryStream ms = new MemoryStream();ms = PersistenceManager.Save(grid);
Now you have a stream and can save to whatever store you want. Want a string you can look at, store, or print to a file quick?
var sr = new StreamReader(ms); var myStr = sr.ReadToEnd();
Another nice thing about specifying properties is that you can do it in XAML or Code, and you can override settings from XAML in Code.Code for settings:
PersistenceSettings settings = new PersistenceSettings(); settings.SavePersistenceOptions = PersistenceOption.OnlySpecified; PropertyNamePersistenceInfo prop = new PropertyNamePersistenceInfo(); prop.PropertyName = "ColumnMovingSettings"; settings.PropertySettings.Add(prop); // Save with specified settings
XamGrid grid = devGrid as XamGrid; ms = new MemoryStream(); ms = PersistenceManager.Save(devGrid, settings);
Load Persistence From Stream:
MemoryStream ms = stream; PersistenceManager.Load(grid, ms);
Load Persistence From Stream with Specific settings:
PersistenceSettings settings = new PersistenceSettings(); settings.LoadPersistenceOptions = PersistenceOption.OnlySpecified; // Add properties here// Load stream with settings specifiedPersistenceManager.Load(grid, ms, settings);
What properties?
With all the properties available in the grid you might think it would take a while to figure out which ones you want to use if your going to specify them. Fortunately it was easier than I thought to store the properties I was interested in. I managed to specify column size, column order, sorting, grouping, columns hidden/shown, and filter settings, all with the lines below.
I ended up using the following properties:
<ig:PersistenceSettings SavePersistenceOptions="OnlySpecified" LoadPersistenceOptions="OnlySpecified"> <ig:PersistenceSettings.PropertySettings>
<ig:PropertyNamePersistenceInfo PropertyName="ColumnResizingSettings"/> <ig:PropertyNamePersistenceInfo PropertyName="ColumnMovingSettings"/> <ig:PropertyNamePersistenceInfo PropertyName="SortingSettings"/> <ig:PropertyNamePersistenceInfo PropertyName="ColumnChooserSettings"/> <ig:PropertyNamePersistenceInfo PropertyName="GroupBySettings" Options="Contains"/> <ig:PropertyNamePersistenceInfo PropertyName="Columns[].FilterColumnSettings" Options="Contains"/>
So this doesn't work for me I get a stack overflow error everytime i try this.
<ig:PersistenceManager.Settings><ig:PersistenceSettings SavePersistenceOptions="OnlySpecified" LoadPersistenceOptions="OnlySpecified">
<ig:PersistenceSettings.PropertySettings>
<ig:PropertyNamePersistenceInfo PropertyName="ColumnMovingSettings"/>
<ig:PropertyNamePersistenceInfo PropertyName="SortingSettings"/>
<ig:PropertyNamePersistenceInfo PropertyName="ColumnChooserSettings"/>
<ig:PropertyNamePersistenceInfo PropertyName="GroupBySettings" Options="Contains"/>
<ig:PropertyNamePersistenceInfo PropertyName="Columns[].FilterColumnSettings" Options="Contains"/>
</ig:PersistenceSettings.PropertySettings>
</ig:PersistenceSettings> </ig:PersistenceManager.Settings>
I am using two button one to save and one to load the settings. it saves fine in my viewmodel property. but when loading i always get a stack over flow exception and i dont know why
Hello beagle77,
I am not sure what may cause this behavior on your side. Would you please provide me with a small sample where this issue is reproducible so I can investigate it further.
Thanks in advance.
I attached a broken down version of what i am trying to do...
once i hit load button to load the settings I get a stack Overflow error.
We have created a new support ticket for you CAS-96776-KWS88Z in our and we have logged this behavior in our internal tracking system with id 117739. We have provided you with more details on this through the support ticket.
I use Save/LoadCustomization all over the place, and it works fine across sessions. I save the customizations in a database and reload when they access the application again. I actually find it to be a much less problematic and compact way to save the customizations (probably because it is specific to the control, and not generalized like the Persistence Framework).
Hi,
I am trying to use the same with XamDataGrid and getting the error "An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll" during Load.
Is there a service pack available for WPF control? I am using Infragistics 12.2 Build#2202. Could you please help?
I thought of using XamDataGrid.SaveCustomizations() and XamDataGrid.LoadCustomizations() instead, but looks like it has to be within the same session and cannot be stored for later use. Any other suggestions/recommendations?
Thanks,
Parvez.
Looks like they only fixed it for the Silverlight assemblies. From the SL release notes:
Control Persistence Framework
Bug Fix
System.StackOverflowException is thrown when loading settings
But no similar note is in the WPF release notes.
I installed the August SR for WPF, and am still experiencing the StackOverflow.
The August SR does fix the StackOverflow exception.