I am saving the columns of a XAMGrid using the persistance manager. If I add a new column to the grid and then load the settings back in, the new columns are no longer there and cannot be shown.
HI Edwin,
You could wire up the PersistenceSettings' Objects' Loaded Event. In that event you could add the new columns.
Here is a code snippet:
ObservableCollection<Person> people = new ObservableCollection<Person>();
PersistenceGroup _SettingsGroup;
PersistenceSettings settings;
string fileName = "TEST";
public MainPage()
{
InitializeComponent();
_SettingsGroup = (PersistenceGroup) LayoutRoot.Resources["SETTINGS"] as PersistenceGroup;
settings = (PersistenceSettings)LayoutRoot.Resources["ColumnSettings"] as PersistenceSettings;
settings.Events.PersistenceSaved += new EventHandler<PersistenceSavedEventArgs>(Events_PersistenceSaved);
settings.Events.PersistenceLoaded += new EventHandler<PersistenceLoadedEventArgs>(Events_PersistenceLoaded);
}
void Events_PersistenceLoaded(object sender, PersistenceLoadedEventArgs e)
//throw new NotImplementedException();
foreach (Column c in xgrid1.Columns)
int i = int.Parse(c.Tag.ToString());
xgrid1.Columns.Remove(c);
xgrid1.Columns.Insert(i, c);
Sincerely,
MattDeveloper Support Engineer
I would like to have a more general solution. I have an application with several windows and some window have multiple grids. Keeping code the handle all of the cases for new columns will be messy over time.