Hi there,
I implemented the XamDockManger with my ViewModel, as described in one of your Blogs and it works like a charm (http://es.infragistics.com/community/blogs/blagunas/archive/2013/09/24/xamdockmanager-data-binding-contentpanes-with-mvvm.aspx).
But now I’m facing a problem when I want so save and reload the current layout, because after loading the layout the TagGroupPane with its behavior will not be recreated like I defined it before. This mean that no new added Items to my ItemsSource will be added to the XamDockManager anymore.
I think this happens because the load-event takes my existing panes and add them to a new TagGroupPane, because I haven’t set a Name to my TagGroupPane w/ behavior. But as soon I add a Name to one of my DocumentPane, SplitPane or TagGroup I get an exception that “An item with the same key has already been added” while trying to load the layout.
But as far as I can see the above blog-example shows a way where only one TagGroupPane have and should have the ItemSourceBehaivor, otherwise every TagGroupPane will add the new Item to his own panes.
So now I’m trying to archive an implementation of the XamDockManger with DataBinding its ContentPane to one main TagGroupPane and the ability to save and load my configuration and still have the CollectionChanged handling after I did my loading.
I created a small example and some use-cases:
Rearrange the panes, add new => new tab is shown
Rearrange the panes, save layout, load layout, add new => new tab is not shown
Rearrange the panes, save layout, add new, load layout, add new => old TagGroupPane w/behavior will be “added” and all other (new and old) panes will be also displayed in it + adding new panes still works
Rearrange the panes, save layout, restart app, add new, load layout => old TagGroupPane w/behavior will be “added” and only the new panes will be displayed in it + adding new panes still works
BR
Andreas Hensel
Hi Andreas,
It looks like the exception I'm seeing is a bug in the control itself so I have asked our engineering staff to examine it further. As for a code-behind based solution, I used the following to reattach the behavior after the LoadLayout call:
var contentHost = this.dockManager.Content as DocumentContentHost; TabGroupPaneItemsSourceBehavior behavior = new TabGroupPaneItemsSourceBehavior(); behavior.HeaderMemberPath = "Header"; behavior.HeaderTemplate = (DataTemplate)dockManager.Resources["HeaderTemplate"]; behavior.ItemTemplate = (DataTemplate)dockManager.Resources["ItemTemplate"]; BindingOperations.SetBinding(behavior, TabGroupPaneItemsSourceBehavior.ItemsSourceProperty, new Binding("Items")); System.Windows.Interactivity.Interaction.GetBehaviors(contentHost.Panes[0].Panes[0]).Add(behavior);
If the x:Name stuff worked this would not be necessary as the dock manager would just reuse the exist TabGroupPane which means the behavior would not be lost. I created a private support case for you so that I can link the development issue to your case. This will let you track the status of the issue. The case number is CAS-167601-F8H1B6 and you can view it here. The dev issue ID is 211257.
Hi Rob,
Thanks for your quick response and looking into it. And it’s good to know that my first assumption of this behavior was sort of right.
At this point I’m also quite open for a code-behind based solution :)
Andreas
The main reason why the behavior stops working after a LoadLayout is because the TabGroupPane was replaced. Since the behavior is still on the old one and has not been moved to the new TabGroupPane, the add button doesn't show a new pane. I thought maybe you could give the TabGroupPane a name so that it would be reused by the XamDockManager but it looks like this just causes another exception based on the pane location. I'm currently looking into this to see if I can get it working. I'll let you know once I have something.