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

Cancel in a previewClosedEvent doesn't Work (Q1)

7 Answers 70 Views
Window
This is a migrated thread and some comments may be shown as answers.
Ludovic Alcala
Top achievements
Rank 1
Ludovic Alcala asked on 23 Mar 2010, 11:55 AM
Hello,
i use a radwindow, and when i cancel the PreviewClosed Event, it loop two times in my event,
Any idea ?

My Code :
this.PreviewClosed += new EventHandler<WindowPreviewClosedEventArgs>(RadWindow_PreviewClosed);

private void RadWindow_PreviewClosed(object sender, WindowPreviewClosedEventArgs e)
        {
                if (validatorManager.globalFormChange)
                {
                    e.Cancel = true;
                    RadWindow.Confirm(new DialogParameters
                    {
                        Header = "Enregistrement",
                        Content = "Souhaitez vous enregistrer avant de quitter?",
                        IconContent = "",
                        OkButtonContent = "Oui",
                        CancelButtonContent = "Non",
                        Closed = new EventHandler<WindowClosedEventArgs>(OnPreviewClosePopup)
                    });
                    return;
                }
            }
        }





I use Q1 2010 309.

Thank you.

7 Answers, 1 is accepted

Sort by
0
Accepted
Miroslav Nedyalkov
Telerik team
answered on 25 Mar 2010, 02:36 PM
Hello Ludovic,

 I were able to reproduce this problem. I logged it in PITS and we will fix for one of the upcoming releases. The title of the issue is "PreviewCloseEvent of the Window is thrown twice of the preview is canceled.".

Sincerely yours,
Miroslav Nedyalkov
the Telerik team

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 Public Issue Tracking system and vote to affect the priority of the items.
0
Ludovic Alcala
Top achievements
Rank 1
answered on 25 Mar 2010, 03:55 PM
Thank you :).
0
Manuel Felício
Top achievements
Rank 1
answered on 05 Apr 2010, 04:32 PM
Hi,

We're having this issue too.
I cancel on the PreviewClosedEvent, tell my UIManager component that the view thats hosted inside this window wants to close and pass a callback that the view's viewmodel will call which confirms if the window can close or not.

As a work around I'm applying states to the window to know exactly when it can close.

        void window_PreviewClosed(object sender, WindowPreviewClosedEventArgs e)  
        {  
            var window = sender as RadWindow;  
            var view = GetView(window);  
 
            if (window.Tag == "CAN_CLOSE")  
                return;  
 
            if (window.Tag == "CLOSING")  
            {  
                e.Cancel = true;  
                return;  
            }  
 
            //window.Tag is null here  
            e.Cancel = true;  
            window.Tag = "CLOSING";  
            manager.TryClose(view, res => 
            {  
                if (res)  
                {  
                    window.Tag = "CAN_CLOSE";  
                    window.Close(); //forces PreviewClosed, hence CAN_CLOSE  
                }  
 
                window.Tag = null;  
            });  
        } 

It's not elegant but it works..
0
Ludovic Alcala
Top achievements
Rank 1
answered on 05 Apr 2010, 04:51 PM
Yes, i did same with private enum but sure it's not a elegant method.
0
Manuel Felício
Top achievements
Rank 1
answered on 05 Apr 2010, 05:14 PM
Definitely not.

Are we gettins this fixed in the next release or maybe it gets fixed in a internal build?

Best regards,

MF.
0
Miroslav Nedyalkov
Telerik team
answered on 06 Apr 2010, 11:56 AM
Hello All,

 This issue will be fixed in one of the upcoming releases. Unfortunately I cannot tell exactly when it is going to be fixed, because it is not scheduled yet.

Kind regards,
Miroslav Nedyalkov
the Telerik team

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 Public Issue Tracking system and vote to affect the priority of the items.
0
Boyan
Telerik team
answered on 17 Jun 2010, 04:38 PM
Hello Manuel FelĂ­cio,

This bug is fixed and will be included in the next internal build. Thank you all for the patience.

Kind regards,
Boyan
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
Tags
Window
Asked by
Ludovic Alcala
Top achievements
Rank 1
Answers by
Miroslav Nedyalkov
Telerik team
Ludovic Alcala
Top achievements
Rank 1
Manuel Felício
Top achievements
Rank 1
Boyan
Telerik team
Share this question
or