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"/>
"It will automatically save/load all properties of the control or only the ones you specify."
I am new to Infragistics and have recently discovered that the above statement is not entirely true. The following is taken directly from the Infragistics documentation.
"There are some types of properties that are not saved by the Infragistics Control Persistence Framework. It does not save AttachedProperties, DataTemplates, Paths, ControlTemplates, Styles, and ItemPanelTemplates."
[SOURCE: About Infragistics Control Persistence Framework]
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.