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.
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.
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.
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.
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.
Please disregard the last post. I'm assuming I must have my own close button to bind to a command in my VM. If so, I have a few problems:
1. How to hide the close button in the DCH. CloseButtonVisibility only works outside the DCH.
2. How to position my close button where, or near, the hidden close button was on the floating panes.
I resolved #1 and marked this as answered.
However, if you have any good ideas for #2, please post. I can't figure out how to get a close button near, or even close, to the right border of a floating pane. The header template has limitations. Again, this assumes I need my own button for viewmodel binding.
I have been looking into your post!
Just to make sure - you want to change the close button of a Floating Pane of the XamDockManager and you want to bind your own command to the mentioned button?
Would it be possible for you to provide me with a screenshot of the window for which you want to change the close button? This way I would be able to further investigate this issue for you.
Thank you for the cooperation. Looking forward to hearing from you.
Thank you for the feedback. I am glad, that you have found a solution to your issue.
Thanks, but I've got this resolved enough for now.