This is a migrated thread and some comments may be shown as answers.

Close Event Not Firing

8 Answers 568 Views
Docking
This is a migrated thread and some comments may be shown as answers.
Sean
Top achievements
Rank 2
Sean asked on 22 Sep 2015, 08:37 PM

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 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~

8 Answers, 1 is accepted

Sort by
0
Sean
Top achievements
Rank 2
answered on 23 Sep 2015, 01:25 PM

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 () 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 is loaded within the main dock. 

That dock has a PreviewClose event on it. I just created a delegate that the loaded subscribes to. Then, when the is closed, it is closed, I check to see if that had and if so, then handle it. I also removed the RadDocking from the , 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 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~

0
Nasko
Telerik team
answered on 24 Sep 2015, 05:42 AM
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
0
Sean
Top achievements
Rank 2
answered on 24 Sep 2015, 11:37 AM

Thanks ,

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

In the PreviewClose event, the 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;
            (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 being acted on.

 

Sean~

0
Nasko
Telerik team
answered on 25 Sep 2015, 01:54 PM
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
0
Sean
Top achievements
Rank 2
answered on 25 Sep 2015, 02:01 PM

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

 

Sean~

0
Sean
Top achievements
Rank 2
answered on 25 Sep 2015, 02:07 PM

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~

0
Sean
Top achievements
Rank 2
answered on 25 Sep 2015, 02:43 PM

Nasko,

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

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

 

Sean~

0
Accepted
Nasko
Telerik team
answered on 25 Sep 2015, 03:02 PM
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
Tags
Docking
Asked by
Sean
Top achievements
Rank 2
Answers by
Sean
Top achievements
Rank 2
Nasko
Telerik team
Share this question
or