PreviewClosed called twice

4 posts, 0 answers
  1. Oliver
    Oliver avatar
    263 posts
    Member since:
    Feb 2011

    Posted 15 Aug 2012 Link to this post

    Hi,

    I'm using VS2008 and Telerik V2012.1.326.35 and a special scenario occured when I'm trying to close a RadWindow.

    In m'y application, I have a flag to detect any user data changes and when the user try to close the RadWindow, if the flag = true, I display a dialog to ask the user if he want to loose his changes or not. If he answer YES, no problem, the RadWindow close without any problem but if he answer NO, the previewclosed event are trigger a second time. The problem occur only when he click on my close button. If he use the upper right X button of the RadWindow, the normal behaviour are respected.

    XAML CLOSE BUTTON:
    ---------------------------------
                    <telerik:RadButton Margin="0 0 5 0" x:Name="btnClose" Click="btnQuit_Click" IsCancel="True">
                        <StackPanel Orientation="Horizontal">
                            <Image Margin="5 0 0 0" Source="Resources/Quit_32x32.png" Height="24" Width="24" />
                            <TextBlock Margin="5" VerticalAlignment="Center" Text="{StaticResource Quit}" />
                        </StackPanel>
                    </telerik:RadButton>
    CODE BEHIND
    ---------------------
            private void btnQuit_Click(object sender, RoutedEventArgs e)
            {
       try
       {               
        Close();
       }
       catch (Exception exc)
       {
        ClientUtilities.DisplayContextEventError(mTracingTool, exc, "BILDT019", "btnQuit_Click");
       }
            }

            private void Me_PreviewClosed(object sender, WindowPreviewClosedEventArgs e)
            {
       try
       {
                    if (IsChangesInProgress && ClientUtilities.ConfirmDialog(this, LocGeneral.GetControlText("Confirmation"), LocGeneral.GetYesNo("CancelChanges")) != true)
                    {
                        e.Cancel = true;
                    }
                    else
                    {
                        DoAction(this, new ActionEventArgs(ActionEvent.Close));

                        // Apply persistence if required.
                        if (mUsePersistence)
                        {
                            string errMsg;
                            PersistenceStorage.Persist(PersistenceStorage.PersistenceAction.Save, this, "BillingModule.BillingDetails" + "." + this.IsReadOnly.ToString(), out errMsg);
                            mIsAlreadyLoaded = false;
                        }
                    }
       }
       catch (Exception exc)
       {
        ClientUtilities.DisplayContextEventError(mTracingTool, exc, "BILDT019", "Me_PreviewClosed");
       }
            }


  2. Boyan
    Admin
    Boyan avatar
    758 posts

    Posted 17 Aug 2012 Link to this post

    Hi Oliver,

    I tried to reproduce the problem but with no success. I have simplified your code as I don't know what the methods in your code behind do, but the event was firing one time as expected. Maybe something that happens in your methods is causing the problem. I have attached the project that I used, could you please modify in order for the problem to be reproducible.

    All the best,
    Boyan
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. UI for WPF is Visual Studio 2017 Ready
  4. Oliver
    Oliver avatar
    263 posts
    Member since:
    Feb 2011

    Posted 17 Aug 2012 Link to this post

    Hi Boyan,

    easy to reproduce, just replace the SHOW by a SHOWDIALOG amd when you click on the button to close, click on OK, PREVIEWCLOSED event should be call twice...

    Thank's
  5. Georgi
    Admin
    Georgi avatar
    348 posts

    Posted 22 Aug 2012 Link to this post

    Hello Oliver,

    We were able to reproduce it using ShowDialog(). So we can confirm that this is an issue and we have logged it here in our Public Issue Tracking System, where you can vote and track the progress of fixing it.


    All the best,
    Georgi
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top