Close Event Not Firing

9 posts, 1 answers
  1. Sean
    Sean avatar
    19 posts
    Member since:
    Jun 2012

    Posted 22 Sep 2015 Link to this post

    I have  an extremely simple layout: A RadDocking control that contains a single RadPane. The pane will always be visible, never floated, etc. Within that pane are some controls, including a ScheduleView.  Like many others have asked, I want to detect when the control closed. I can see the PreviewClose event fire if I allow the pane itself to close. I also see the Close event fire if the pane is closed.

    However, if I close the RadDocking control, the Close event never gets called. What am I missing? I have spent about four hours now tracking down something that should be extremely simple. If I have edited the content of my control, and click the 'x' on the RadDocking control, throw up a message warning the user of unsaved changes. If the user says 'OK', then save the form and close. If they say 'Cancel', stop the process.

    For the life of me I don't see where to hook into events (OnStateChanged is the only event I see firing when the RadDocking closes, and I can delegate the event, but the RadDocking still closes).

    <telerik:RadDocking HasDocumentHost="True"  HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
            <telerik:RadDocking.DocumentHost>
                <telerik:RadSplitContainer IsTabStop="True" Orientation="Vertical" x:Name="SplitContainer">
                    <telerik:RadPaneGroup HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                        <telerik:RadPane CanFloat="False" CanUserPin="False" CanUserClose="True" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" IsTabStop="True" IsDragDisabled="True"> 

     ....controls ...

                        </telerik:RadPane>
                    </telerik:RadPaneGroup>
                </telerik:RadSplitContainer>
            </telerik:RadDocking.DocumentHost> 

     

     

    Thoughts?

    Sean~

  2. Sean
    Sean avatar
    19 posts
    Member since:
    Jun 2012

    Posted 23 Sep 2015 in reply to Sean Link to this post

    I managed, after sleeping on it, to find a solution that works best. I'll post it here for anyone else who happens along.

    Our main window has the 'top level' dock in which all other forms (panes) load when the user clicks the specific button. For example, if they wish to search for products, they click the 'Search Products' button and the pane is loaded within the main dock. 

    That dock has a PreviewClose event on it. I just created a delegate that the loaded pane subscribes to. Then, when the pane is closed, however it is closed, I check to see if that pane had subscribed, and if so, then handle it. I also removed the RadDocking from the pane, since it was not needed. below is the code in the MainWindow:

     public delegate bool HandlePaneClosing();

    public event HandlePaneClosing HandlePaneClosingEvent; 

     private void radDocking_PreviewClose(object sender, Telerik.Windows.Controls.Docking.StateChangeEventArgs e)
     {

               if(HandlePaneClosingEvent != null)

                {
                    if(!HandlePaneClosingEvent())
                    {
                        e.Handled = true;
                    }         
                }

    }

     

    The pane itself has this in its constructor:

     MainWindow = (MainWindow)Application.Current.MainWindow;
                if (MainWindow != null)
                {
                    MainWindow.HandlePaneClosingEvent += HandleSave;
                }

     

    Pretty simple, once I actually thought about it.

     

    Sean~

  3. UI for WPF is Visual Studio 2017 Ready
  4. Nasko
    Admin
    Nasko avatar
    586 posts

    Posted 24 Sep 2015 Link to this post

    Hello Sean,

    We are really glad to hear that you were able to find a suitable solution for your scenario and thank you for sharing it with the other members of the community.

    Please, do not hesitate to contact us if you have any additional questions or concerns regarding Telerik controls.

    Regards,
    Nasko
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  5. Sean
    Sean avatar
    19 posts
    Member since:
    Jun 2012

    Posted 24 Sep 2015 in reply to Nasko Link to this post

    Thanks nasko,

    I would like to ask, however, about why the preview close event passes down the first pane in the collection rather than the pane being closed. For example, say I have two panes open in the dock and I modify one of the forms data. For some reason i stop and go to the other pane, do what I need to do, and then close that second form.

    In the PreviewClose event, the pane being passed down is the first one. The only way I found to handle a situation where multiple panes are open is to check 'IsSelected' before handling the event. See my code snippet below:

     

                var radDock = sender as RadDocking;
                var paneList = radDock.Panes;
                foreach (Screens.PCSPane pane in paneList)
                {
                    if (pane.IsSelected)
                    {
                        if (!pane.HandlePaneClosingEventEventIsNull())
                        {
                            e.Handled = pane.HandleClosingEvent();
                            pane.RemoveFromParent();
                            break;
                        }
                        if (!pane.HandleListenerDetatchEventIsNull())
                        {
                            pane.HandleDetatchEvent();
                        }
                    }
                }

     

    Again, the solution works for my purposes, but I would think that the StateChangeEventArgs would carry with it the pane being acted on.

     

    Sean~

  6. Nasko
    Admin
    Nasko avatar
    586 posts

    Posted 25 Sep 2015 Link to this post

    Hi Sean,

    The observed by you behavior of the PreviewClose event is not an expected one. Only the pane that is going to be closed should be in the Panes collection of the event argument - if you close a few panes at the same time the event should fire for each pane separately. Please, check the attached video that demonstrates that and let us know if we didn't miss something.

    Could you please try to isolate that behavior in a sample project and send it back to us, so we could investigate it further?

    We are looking forward to hearing from you.

    Regards,
    Nasko
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  7. Sean
    Sean avatar
    19 posts
    Member since:
    Jun 2012

    Posted 25 Sep 2015 in reply to Nasko Link to this post

    I apologize Nasko, the rar file has an .swf file and I cannot see the flash.

     

    Sean~

  8. Sean
    Sean avatar
    19 posts
    Member since:
    Jun 2012

    Posted 25 Sep 2015 in reply to Sean Link to this post

    Nevermind again... I am used to seeing your code, not watching a video. :)

    I opened it in my browser and viewed the demo.

    It is interesting that your even worked as I expected. I will try to replicate my issue in a mini project.

     

     

    Sean~

  9. Sean
    Sean avatar
    19 posts
    Member since:
    Jun 2012

    Posted 25 Sep 2015 in reply to Sean Link to this post

    Nasko,

     I stand corrected. You were correct. I am unsure why, when I was looking, it appeared that the incorrect pane was being passed down, but it looks correct. I have modified my code accordingly.

    Thanks, again, for the promt response and the demo you  provided.

     

    Sean~

  10. Answer
    Nasko
    Admin
    Nasko avatar
    586 posts

    Posted 25 Sep 2015 Link to this post

    Hello Sean,

    I am really glad I was able to help you.

    If you need our assistance concerning any other additional questions about Telerik controls, please do not hesitate to contact us.

    Regards,
    Nasko
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top
UI for WPF is Visual Studio 2017 Ready