Hello,
We use a xamDockManager in our project which contains several SplitPanes and ContentPanes inside them.
This panes can ba added/removed dynamically based on users actions.
Everything is working fine except in this case :
We have a ContentPane in a SplitPane. The ContentPane is docked. Then we unpin it. So, the parent of the ContentPane is now an UnpinnedTabArea.
And we would like to remove it from the UnpinnedTabArea, in code.
This is how it looks : (pane is the ContentPane)
if (pane.Parent != null && (pane.Parent is SplitPane || pane.Parent is UnpinnedTabArea)) {
if (pane.Parent is SplitPane) ((SplitPane)pane.Parent).Panes.Remove(pane);
if (pane.Parent is UnpinnedTabArea) {
}
The first instruction (pane.Parent is SplitPane) is working fine (the pane.Parent property is set to null after the remove instruction and we can add it anywhere we want).
For the second instruction (pane.Parent is UnpinnedTabArea), we try different options but it's always impossible to access and modify the items collection of the unpinnedtabarea.
Thank you in advance for your answers,
JC
Hello JC,
Thank you for your post. I have been looking into it and I can suggest you call the ExecuteCommand method of the ContentPane with ContentPaneCommads.Close as a parameter like this:
pane.ExecuteCommand(ContentPaneCommands.Close);
This way the code will work in both ways, when the Parent is SplitPane and UnpinnedTabArea. Please let me know if this helps you or you need further assistance on this matter.
Looking forward for your reply.
Hello Stefan and thanks for your reply.
Your instruction works fine and it indeed closes the pane.
The problem is that I need to put it directly, after that, in a SplitPane with a splitpane.Panes.Add(pane) instruction.
When I execute your code, I have the same problem as before : the pane.Parent is still attached to the UnpinnedTabArea.
So the splitpane.Panes.Add instruction fails to execute.
I tried some pane.InvalidateVisual() kind of things (I know it's not very recommanded) but it doesn't work.
Thank you,
It seems like that I am missing something in your scenario, so could you please send an isolated sample project, where the issue is reproduced, so I can investigate it further for you.
Hello Stefan,
Here is a sample project.
You have two panes and the goal is to be able to reset their positions after making them go anywhere.
It works fine except when you unpin the panes.
Note that we can't use the loadlayout/savelayout method because we need to add our panes dynamically by code.
I have modified the sample you have sent me, so now it works as you want. Basically I used the TogglePinnedState command in order to change the parent of the unpinned ContentPane to SplitPane. Also I used a Dispatcher in order to delay the serialization, otherwise the ContentPane’s Parent wasn’t reset to SplitPane. Please let me know if this helps you or you need further assistance on this matter.
Thank you for your feedback. I am glad that you resolved your issue and I believe that other community members may benefit from this as well.
Thanks again.
Yes, it works perfectly !
Big thanks :)