In my application I used to use the wpf windows where are extendd from System.WIndows.Window.
I am thinking of migrate them to using Ribbon Windows which are extended From ToolWindow.
Unfortunately I can't use the OnClosing event with Ribbon windows.
How can I trigger when a window is closed?
I need something like the following
protected override void OnClosing(CancelEventArgs e) {
e.Can开发者_如何学Gocel = true;
}
Thanks
Try this: on XAML add Closing
<ribbon:RibbonWindow x:Class="RibbonWindowSample.RibbonWindowWord"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ribbon="http://schemas.microsoft.com/winfx/2006/xaml/presentation/ribbon"
xmlns:local="clr-namespace:RibbonWindowSample"
Title="RibbonWindowWord" Height="600" Width="1000"
Closing="RibbonWindow_Closing"
>
<TextBlock Text="Hello" />
</ribbon:RibbonWindow>
on Code add
private void RibbonWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
if (MessageBox.Show("Confirm?", "Confirm", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
e.Cancel = true;
}
精彩评论