X를 클릭하면 작동하는 메인 창에 Closing 이벤트 코드가 추가되었으며 문제없이 이벤트를 취소 할 수 있습니다 (" ? 확인 나는 아이콘을 더블 클릭하면 그것은 RibbonWindow_Closing
이벤트에 내 중단 점에 도달하지만, e.Cancel
이 true로 설정된 경우는 것처럼, 어쨌든 밖으로 닫히고,응용 프로그램 처리하기 아이콘에서 전화 걸기
불행하게도 "유형 대화와 닫는 이벤트)를 저장해야합니다 그 Application.Current.Shutdown()
Alt-F4 (및 아이콘 -> 닫기) 및 X 버튼이 모두 올바르게 처리되지만 아이콘 자체를 두 번 클릭하지 않습니다.
왜 이런 일이 발생하는지 알고 있습니까? 프리즘 (Prism)을 사용하고 있는데 문제가된다면 부트 스트 래퍼 (bootstrapper)가 메인 윈도우를 만듭니다. 여기
는, 내 RibbonWindow_Closing 이벤트를 치는 이외의 모든 외부 코드 스택 추적입니다 :MyProgram.exe!MyProgram.Shell.RibbonWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e) Line 64 C#
PresentationFramework.dll!System.Windows.Window.OnClosing(System.ComponentModel.CancelEventArgs e) + 0x91 bytes
PresentationFramework.dll!System.Windows.Window.WmClose() + 0x96 bytes
PresentationFramework.dll!System.Windows.Window.WindowFilterMessage(System.IntPtr hwnd, int msg, System.IntPtr wParam, System.IntPtr lParam, ref bool handled) + 0xe5 bytes
PresentationCore.dll!System.Windows.Interop.HwndSource.PublicHooksFilterMessage(System.IntPtr hwnd, int msg, System.IntPtr wParam, System.IntPtr lParam, ref bool handled) + 0x7e bytes
WindowsBase.dll!MS.Win32.HwndWrapper.WndProc(System.IntPtr hwnd, int msg, System.IntPtr wParam, System.IntPtr lParam, ref bool handled) + 0xbe bytes
WindowsBase.dll!MS.Win32.HwndSubclass.DispatcherCallbackOperation(object o) + 0x7d bytes
WindowsBase.dll!System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate callback, object args, int numArgs) + 0x53 bytes
WindowsBase.dll!MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(object source, System.Delegate method, object args, int numArgs, System.Delegate catchHandler) + 0x42 bytes
WindowsBase.dll!System.Windows.Threading.Dispatcher.InvokeImpl(System.Windows.Threading.DispatcherPriority priority, System.TimeSpan timeout, System.Delegate method, object args, int numArgs) + 0xb4 bytes
WindowsBase.dll!MS.Win32.HwndSubclass.SubclassWndProc(System.IntPtr hwnd, int msg, System.IntPtr wParam, System.IntPtr lParam) + 0x104 bytes
[Native to Managed Transition]
[Managed to Native Transition]
PresentationFramework.dll!System.Windows.Window.InternalClose(bool shutdown, bool ignoreCancel) + 0xa1 bytes
PresentationFramework.dll!System.Windows.Application.DoShutdown() + 0x1b6 bytes
PresentationFramework.dll!System.Windows.Application.ShutdownImpl() + 0x1c bytes
PresentationFramework.dll!System.Windows.Application.ShutdownCallback(object arg) + 0x5 bytes
WindowsBase.dll!System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate callback, object args, int numArgs) + 0x53 bytes
WindowsBase.dll!MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(object source, System.Delegate method, object args, int numArgs, System.Delegate catchHandler) + 0x42 bytes
WindowsBase.dll!System.Windows.Threading.DispatcherOperation.InvokeImpl() + 0x8d bytes
테스트 RibbonWindow, 메시지를 제공하지만 여전히 닫
<ribbon:RibbonWindow x:Class="MyProject.TestShell"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ribbon="clr-namespace:Microsoft.Windows.Controls.Ribbon;assembly=RibbonControlsLibrary"
Title="TestShell" Height="300" Width="300" Closing="Window_Closing">
<Grid>
<DockPanel LastChildFill="True">
</DockPanel>
</Grid>
</ribbon:RibbonWindow>
이것은 일반 창으로 작동
는 메시지를 확인하고이 열려 :
<Window x:Class="MyProject.TestShell"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="TestShell" Height="300" Width="300" Closing="Window_Closing">
<Grid>
<DockPanel LastChildFill="True">
</DockPanel>
</Grid>
</Window>
코드 뒤에 간단하다 :
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
e.Cancel = true;
MessageBox.Show("No close!");
}
업데이트
내가되는 좁혀 확인 RibbonWindow 컨트롤에 문제가 발생하면 아이콘을 두 번 클릭하면 응용 프로그램이 종료됩니다. 서브 윈도우가이 같은 방식으로 닫혀있는 경우
은 분명히 그것은 또한 기본 응용 프로그램을 닫습니다 : 나는 분명히 응용 프로그램을 shutsdown의 RibbonWindow 제어에 문제가있는 좁혀 http://social.msdn.microsoft.com/Forums/en/wpf/thread/3e9cdc9c-dfb7-49f2-923a-ead07504d568/// <summary>
/// This handles the click events on the window icon.
/// </summary>
/// <param name="sender">Click event sender</param>
/// <param name="e">event args</param>
private void IconMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
if (e.ClickCount == 1)
{
if (SystemCommands.ShowSystemMenuCommand.CanExecute(null, this))
{
SystemCommands.ShowSystemMenuCommand.Execute(null, this);
}
}
else if (e.ClickCount == 2)
{
if (ApplicationCommands.Close.CanExecute(null, this))
{
ApplicationCommands.Close.Execute(null, this);
}
}
}
호출하지. 스택 추적 표시. –
@HansPassant 나는 [External Code]에서 Closing 이벤트로 바뀔 수 있었으면 좋겠다. 보낸 사람은 내 셸 창이고 내가하는 첫 번째 작업은 (CancelEventArgs e) e.Cancel = true로 설정됩니다. Repro = Reproduction을 의미합니까? 왼쪽 상단의 아이콘을 두 번 클릭하면 닫을 때 취소 할 수 있습니까? – John
@HansPassant 내 코드를 디버깅하지 못하게하고 OP를 업데이트해야했습니다. – John