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 Johannes,
Are you applying custom Persistence settings?
When you say that all of the cells are empty, are you saying that the columns are appearing, and the cells are just empty, or that no columns appeared?
Do you think you could post a simplified version of your sample that i can look at?
Thanks
-SteveZ
Hi Steve,
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".
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 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.
Regards,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,
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!
This is now logged in Development (ref issue 37084), and you will be notified through a support case when this issue is fixed.
We're definitely going to look into the issue, and there will be a bug case created so that you'll be notified of the resolution.
I'm glad the workaround will work for you for now.
sorry for my late reply. We got a lightning strike over here and all the telephone lines were cut off. So I spent some time with other things.
I tried your suggestion and it principially works. Together with your suggestion to detach the ItemsSource and attach again after load the grid will also show the content of the TemplateColumn correctly.
I will spent some more time on this and will mark your suggestion as answer when I do no found any more.
Nevertheless: Do you have opened a bug case or shall I have to live with the workaround?
Johannes
So in Silverlight, its impossible for us to actually save certain types, such as DataTemplate, however we do provide a workaround for situations like that. Specifically, if you define your DataTemplate in your App.Xaml, and put an attached property on it, that will allow us to look it up, we can store that identifier, and reload the DataTemplate from the app.xaml when it loads back up.
The following help article explains this in more detail.
http://help.infragistics.com/NetAdvantage/Silverlight/2010.2/CLR4.0/?page=Persistence_Identifier.html
I had to add some additional information which you can add to the bug reporting:
With your provided workaround it isn't possible to restore the TemplateColumns. At this type of column the cells still remains empty. Also in case of there is a ToolTipContentTemplate specified for a column after the Load it doesn't gets loaded.
For the moment I can live with the workaround, but finally I need to be able to personalize also TemplateColumns. Do you know any way to exclude the "DataTemplate" specification of the DataTemplate which makes the trouble?