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
744
How to pass document close event to child?
posted

Hello,

I'm adding some usercontrols to the documenthost via code something like:-


myContentPane = MyXamDockManager.AddDocument("Test Header",null);
myContentPane.Content = new ContentUserControl(...);
myContentPane2 = MyXamDockManager.AddDocument("Test Header 2",null);
myContentPane2.Content = new ContentUserControl(...);

How can I allow the individual instances ContentUserControl to handle the closing event (when the user clicks the cross on the document tab header), eg to prompt the user to save an unsaved document or close without saving?

Thanks,

- Anthony

  • 69686
    posted

    Hello Anthony,

    The content panes that you add in the Document Content Host will still raise their Closing/ed events when you try to close them, so you can handle and cancel them if you need.

     

    ContentPane cp = xamDockManager1.AddDocument("AddedContentPane", new Button());

    cp.Closing += new EventHandler<PaneClosingEventArgs>(OnClosing);