In order to handle CP closing MVVM-style, I was prepared to use the CP HeaderTemplate to include a button to which I could attach a RelayCommand, and hide the stock close button. As of the most current release, is this still the recommended way to do this? How about when the CP is not in the DCH? I haven't tried that yet, but it seems like I wouldn't be able to get the button as far to the right as the stock close button on the floating caption. Thanks.
Actually, this is now a small mess. I think I need to know the binding property/ancestor for the close command to execute in a viewmodel when the contentpane is in any of its states (pinned, unpinned, floating, etc.).
I've found when the pane originates in the DCH, and is floated, and later docked/pinned/etc., the viewmodel close commands cease to work properly at all, as if the pane exists in different collections.
To be as clear as I can,
1. Do I have to have my own close button to bind to an ICommand?
2. What is the recommended approach for panes not in the DCH? If the answer to #1 is yes, I would need to hide the stock close button, and I'm not certain how far to the right I could get my own close button.
Thanks again.
Gergana,
Thank you for the response. You have answered the first half of my question. However, I will need to bind to my own close command, unless a command property has been exposed on your close button.
I think I wasn't clear about the second half. When a pane is not in the DCH, I will still need a custom close button in order to bind to my viewmodel. I was wondering the recommended approach for that, since it seems, at best, it would have to lay inside the active pane dropdown.
Hello Darryl,
Thank you for your posts!
I have been looking into then. If you want to be able to close the ContentPanes, that are inside a DocumentContentHost I can suggest to set the TabHeaderTemplate property to a custom template, that has a button and TextBlock in it.
In order for the button to look like the a close button you can set its style property and apply the DocumentCloseButtonStyleKey, which is used for the other close buttons, that are in the XamDockManager. Then you can use the Close command from the ContentPaneCommands.
In order to be able to close a pane, that is not inside a DocumentContentHost you can simply set the AllowClose property of the ContentPane.
I have created a small sample application for you in order to show you the above mentioned functionality. Please find the attached sample application and feel free to let me know if you have any further questions on this matter.
also, I don't have to have a close button in the tab header, it just seems a logical place if I have to have a new button for the ICommand. It would be fine with me if I could somehow bind an ICommand to the stock CP close buttons. Thanks.