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");
}
}