当发生DispatcherUnhandledException事件时,是否有可能(如果可以的话)在App.xaml.cs中重置光标。
在发生意外情况后进行清理。
答案 0 :(得分:1)
假设您的意思是鼠标光标并且您想阻止应用程序崩溃:
<强>的App.xaml 强>
<Application x:Class="WpfApplication1.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow.xaml"
DispatcherUnhandledException="Application_DispatcherUnhandledException">
<Application.Resources>
</Application.Resources>
</Application>
<强> App.xaml.cs 强>
private void Application_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
{
// resets the cursor
Mouse.OverrideCursor = null;
// prevents the app from crashing
e.Handled = true;
}