Hi all,
I am using a XamGrid as a global control placed in my masterpage;
Throughout the application life it needs to change data many time, regarding the page it is on
In XAML I have:
ItemsSource="{Binding GridDataCollection}"
I also change the columns of the grid; For this, my ViewModel sends a message to the view and it creates the columns(there was no way of doing this otherway before, is there some binding technique for this now?)MY PROBLEM: From the second creation of columns on, I get an exception when creating columns for the grid;(Invalid Key exception is thrown)When I create these columns, they must correlate with the ItemsSource type of items;WITH DEBUGGING:- I have seen that the ItemsSource property still contains the elements from the previous grid!- Assured that the creation of columns is triggered after DataContext property is changed- The ItemsSource property was refreshed on the third loading with data from the second loadingPlease tell me how can I know when to create my Columns? When the ItemsSource will be changed?I really need a fix for this and I will appreciate any kind of help or hintsThanks in advance
Well the first thing that I would check is that the GridDataCollection property raises in INotifyPropertyChanged notification. But the columns would be mapped to your old collection type.
If you were autogenerating your columns I would say just set the ItemSource to null prior to putting your new typed collection on. This would autoclear all autogenerated columns. Since you are making your columns you would need to self clear the columns (and column layouts) prior to setting your new ItemSource, otherwise the grid would attempt to map members of your collection the columns that you already have.