Cancel in a previewClosedEvent doesn't Work (Q1)

8 posts, 1 answers
  1. Ludovic Alcala
    Ludovic Alcala avatar
    24 posts
    Member since:
    Jan 2010

    Posted 23 Mar 2010 Link to this post

    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.
  2. Answer
    Miroslav Nedyalkov
    Admin
    Miroslav Nedyalkov avatar
    1718 posts

    Posted 25 Mar 2010 Link to this post

    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.
  3. DevCraft banner
  4. Ludovic Alcala
    Ludovic Alcala avatar
    24 posts
    Member since:
    Jan 2010

    Posted 25 Mar 2010 Link to this post

    Thank you :).
  5. Manuel Felício
    Manuel Felício avatar
    64 posts
    Member since:
    Oct 2009

    Posted 05 Apr 2010 Link to this post

    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..
  6. Ludovic Alcala
    Ludovic Alcala avatar
    24 posts
    Member since:
    Jan 2010

    Posted 05 Apr 2010 Link to this post

    Yes, i did same with private enum but sure it's not a elegant method.
  7. Manuel Felício
    Manuel Felício avatar
    64 posts
    Member since:
    Oct 2009

    Posted 05 Apr 2010 Link to this post

    Definitely not.

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

    Best regards,

    MF.
  8. Miroslav Nedyalkov
    Admin
    Miroslav Nedyalkov avatar
    1718 posts

    Posted 06 Apr 2010 Link to this post

    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.
  9. Boyan
    Admin
    Boyan avatar
    758 posts

    Posted 17 Jun 2010 Link to this post

    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
Back to Top
DevCraft banner