Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1830
EventTrigger for Contentpane Closing
posted

I'm using MVVM and I need to be able to cancel contentpane close events in a viewmodel class.  Originally I thought to use a HeaderTemplate with my own close button, but there are a few scenarios where the stock close button will still show up in a floating window, even if you turn it off with CloseButtonVisibility, and I don't want to re-template any of the DockManager controls.  The goal is to handle the closing event for all panes in the viewmodel.  Therefore, I'm wondering if I can set up an interaction trigger to invoke a command action for the contentpane's closing event.

Does anyone know how to do this? Any other ideas for a complete MVVM-style contentpane close architecture are also welcome.  Thanks.

Parents
No Data
Reply
  • 1830
    Offline posted

    There are a few areas of basic infrastructure (i.e. closing) that appear to not lend themselves to an MVVM apporach apart from re-templating (a daunting thought given the complexity of this massive control).  However, I believe I have a decent enough workaround.  I'm using Brian Lagunas' attached behavior, and I added the following line of code to the PrepareContainerForItem method:

    container.Closing += (s, e) => e.Cancel = !(item as ViewModel).Close();

    which provides an adapter of sorts to map ContentPane.Closing events into the viewmodel plumbing.

Children