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

PreviewClosed called twice

3 Answers 103 Views
Window
This is a migrated thread and some comments may be shown as answers.
Oliver
Top achievements
Rank 1
Oliver asked on 15 Aug 2012, 02:10 PM
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");
   }
        }


3 Answers, 1 is accepted

Sort by
0
Boyan
Telerik team
answered on 17 Aug 2012, 04:12 PM
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.

0
Oliver
Top achievements
Rank 1
answered on 17 Aug 2012, 08:05 PM
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
0
Georgi
Telerik team
answered on 22 Aug 2012, 07:43 AM
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.

Tags
Window
Asked by
Oliver
Top achievements
Rank 1
Answers by
Boyan
Telerik team
Oliver
Top achievements
Rank 1
Georgi
Telerik team
Share this question
or