Hi there,
I’m trying to implement your xamDockManager in our application but I stumbled over the behavior that a floating pane will be removed from the xamDockManager controls visual tree.
But first a short introduction of my implementation. At first I implemented the behavior that allows me to bind to a collection, which represents my views (http://ko.infragistics.com/community/blogs/blagunas/archive/2013/09/24/xamdockmanager-data-binding-contentpanes-with-mvvm.aspx). In the panes I show a xamDataGrid with the ability to dynamically add/remove columns from the grid and I give every column its own style, depending on various cases. So most of my UnboundFields have an own unique style.
But because of the above mentioned behavior I’m facing now the problem that all my column-styles are gone and no values are shown anymore when I move the tab. So obvious I need a solution that allows me to keep my styles without rebuilding them and also save my position of my selected or focused row/column.
I read in several posts/documentation that I should use the ToolWindowLoad/ToolWindowUnload event to set my styles, but at the moment I’m not really sure how I can achieve this.
I created a small example of my current implementation.
BR
Andreas Hensel
Hello Andreas,
Thank you for your post!
I have been investigating into the sample project that you have sent, and I have reproduced this behavior that you are seeing. When a pane is floated in the XamDockManager, it gets recreated into a new pane with a new instance of the content that was inside of it, but it is strange that only the Id column seems to be showing up, as the Loaded event for the grid is still being fired. It seems to me that the ItemTemplates defined for the data types O1 and O2 in your project are being persisted to show only what is in the XAML of your corresponding user control, even though the Loaded events of the grids in those user controls are hit when the pane is floated, and so the columns should be getting added. However, when viewing the visual tree, it does not appear that those columns are added to the floated pane's grid.
I am going to continue to investigate this, and I will have more information for you on this matter soon. Please let me know if you have any other questions or concerns on this matter.
Sincerely,AndrewAssociate DeveloperInfragistics Inc.www.infragistics.com/support
Hello Andrew,
Thank you for your fast respond.
The reason no columns getting added after the pane is floating is that I intentionally prevent a new generation of my view by checking the IsInit-flag on my model in the Loaded-event. I did this because I don’t want to rebuild my whole styles every time when the pane visual tree position is changed.
I hoped there is a solution to actually save my created style and reload it and not just recreate them. I need this behavior because in my application the creating of my styles take some time and the xamDataGrid also need some time to do his magic. Secondly my displayed column/row, active row/cell information getting lost.
BR and I’m looking forward to hear from your investigation
Andreas
I have been collaborating with my colleagues regarding this issue, and it does not appear that you can prevent the ContentPane recreated, but there is a way to stop the content inside of it from being recreated. The template of the content pane (in this case, your UserControl) was getting recreated on float of the pane, and being that you are ignoring the Loaded event every other time except the first one, this is why you are losing your columns. You lose the selection, scroll position, styling, etc, because the pane is not really changing visual tree position as much as it is breaking off into a new one when the pane is floated. In other words, the pane is not in the XamDockManager's visual tree once it is floated.
Instead of modifying the Loaded event or anything that has to do with the user controls, I would recommend that you take a look at the PrepareContainerForItem method of the TabGroupPaneItemsSourceBehavior. The way this method currently exists is to set the Content/ContentTemplate of the ContentPane itself to the elements you have made the template to show. Instead of this, I would recommend that you place a ContentControl as the pane's Content/ContentTemplate and then set the Content/ContentTemplate of the ContentControl instead. This prevents the loss of your element modifications on float of the pane.
I have attached a sample project to demonstrate the above.
Please let me know if you have any other questions or concerns on this matter.
Thank you and your colleagues for helping me in this matter. I implemented your solution in my application and it works like a charm.