0

DispatcherUnhandledException イベントが発生したときに App.xaml.cs でカーソルをリセットすることは可能ですか (可能であればどのように可能ですか)。

不測の事態が起こった後の片付け。

4

1 に答える 1

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;
}
于 2013-09-24T10:40:40.000 に答える