Hi,
I am using the XamGrid v10.2 with the latest service release. I want to persist the grid settings with the PersistenceManager. This works fine, in case of just one band is displayed. But in case of two bands are displayed at restore the all the cells are empty, but the record-count is like expected.
When I comment the definition of the second band out at XAML the persistence save and load procedure works as expected. My data is structured that each top level record will contain four second level records which shall be displayed at the second band.
What I am doing wrong here? I don't really need to store the settings of the child-band therefore I also can exclude this. I tried around with the PersistenceSettings, but I only can exclude each column setting :-(
Can somebody help?
RegardsJohannes
Hi Steve,
the provided workaround works perfectly. I just need to check if I have to unset a ItemsSource at loadFromPersistenceManager() method.
private void loadFromPersistenceManager(Stream stream, DependencyObject obj){ if (stream == null) return; XamGrid grid = obj as XamGrid; System.Collections.IEnumerable databag = null;
if (grid != null) { databag = grid.ItemsSource; grid.ItemsSource = null; }
PersistenceManager.Load(obj, stream); if (grid != null) grid.ItemsSource = databag;}
This makes it very easy to move to real application. Thank you very much!
Regards,Johannes
Hi Johannes,
Ok, so i looked into this a bit deeper, and it appears that is a bug in there. Although i'm not exactly sure where yet.
However, i do have a possible workaround. You can load your default settings like you did before in UserControl_Loaded.
However, in your load method, you'll need to unhook the ItemsSource and reset it up. Basically what appears to be happening, is that when you introduce a ColumnLayout, the grid is recreating columns instead of reusing ones that already existed. But, since the itemsSource is never reintialized, the data types for each column are never properly associated with each column, and thus no bindings are created.
The workaround is to clear the ItemsSource and reset it to the grid afterwards, which will force the grid to hook up each column properly.
PeopleGrid.ItemsSource = null;
PersistenceManager.Load(obj, stream);
PeopleGrid.ItemsSource = People;
I'll have one of our Developer Support Engineers create a bug for this, so we can get to the bottom of the root cause.
Thanks,
-SteveZ
I appreciate your answer and followed your recommendation. But the provided solution doesn't work very well.
I moved the code to the location you recommended and tested it from my client. Now I can click on the buttons above the grid as I want and the cells at the grid will remain filled. But whether the "Restore Default" button nor the "Load Personalization" button will change something at the column width, column position (for column moving) or sorting. With other words: The grid will stay remain as no button was clicked. It seems that the columns of the frist band and the second band are not touched by PersistenceManager for some reason.
Could you please take an additional look to this at your side if you can also reproduce this? Thank you.
At first look, it appears to be a timing issue at when you're saving you're default settings.
When i moved the code for saving tot he Grid's Loaded event, everything worked:
public MainPage()
{
InitializeComponent();
_defaultSettings = null;
PeopleGrid.Loaded += new RoutedEventHandler(PeopleGrid_Loaded);
}
void PeopleGrid_Loaded(object sender, RoutedEventArgs e)
saveAtPersistenceManager(ref _defaultSettings, PeopleGrid);
loadPersistentSettings(PersonlizationFileName, PeopleGrid);
Hope this helps,
I tried something around with custom persistence settings, but with no success. At the attachment you can find a Visual Studio solution which shall enable you to reproduce the issue (at my computer I can reproduce). At this example I did not use custom persistence settings.
When I mean the cells are empty, then the columns are presented and also the correct data record count but the cells where the data should be displayed simply shows nothing (empty cell).
Just to make sure to talk about the same version; I am using the assembly version "10.2.20102.2005".