如何在XAML应用程序中初始化HResult?

时间:2016-05-13 12:45:23

标签: c# wpf xaml win-universal-app windows-10-universal

这篇Speech recognition quickstart文章指示我

  

...将全局变量(HResultPrivacyStatementDeclined)初始化为HResult值0x80045509

代码是:

private static uint HResultPrivacyStatementDeclined = 0x80045509;

catch (Exception exception)
{
  // Handle the speech privacy policy error.
  if ((uint)exception.HResult == HResultPrivacyStatementDeclined)
  {
    resultTextBlock.Visibility = Visibility.Visible;
    resultTextBlock.Text = "The privacy statement was declined. 
      Go to Settings -> Privacy -> Speech, inking and typing, and ensure you 
      have viewed the privacy policy, and 'Get To Know You' is enabled.";
    // Open the privacy/speech, inking, and typing settings page.
    await Windows.System.Launcher.LaunchUriAsync(new Uri("ms-settings:privacy-accounts")); 
  }
  else
  {
    var messageDialog = new Windows.UI.Popups.MessageDialog(exception.Message, "Exception");
    await messageDialog.ShowAsync();
  }
}

但是,我们应该把这些代码放在哪里?在 App.xaml.cs

0 个答案:

没有答案