Stopping notification bar to popup during game play

吃可爱长大的小学妹 提交于 2019-12-09 13:07:30

问题


Context: I am working on a windows phone game using XNA 4.0 framework. During the gameplay, if the user accidentally drags the top of screen, notification center gets dragged down.

I have seen few apps where this behaviour is overridden and instead of notification center popping up, a small cue is shown at the top as shown in the screenshot below.

Question: What is the API that stops notification center to come up when user accidentally drags the top of screen during gameplay?

Screenshot of what I want to achieve:

Same question asked on WP forum also but waiting for correct solution.


回答1:


To hide the notification bar, you need to do two things:

  1. Set your application as full screen
  2. Hide the system tray in your pages

You can set your application as full screen by changing the FullScreen property of your RootFrame. This can be done for instance in the App constructor, in the App.xaml.cs file:

public App()
{
    // Global handler for uncaught exceptions.
    UnhandledException += Application_UnhandledException;

    // Standard XAML initialization
    InitializeComponent();

    // Phone-specific initialization
    InitializePhoneApplication();

    // Hide the notification bar
    // Note: this must be done *after* InitializePhoneApplication
    RootFrame.FullScreen = true;

    // Language display initialization
    InitializeLanguage();
}

Then, you also have to hide the system tray on your pages, by setting the SystemTray.IsVisible property. This can be done either in the C# code or in the XAML:

<phone:PhoneApplicationPage
    x:Class="SL8._1.MainPage"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    shell:SystemTray.IsVisible="False">


来源:https://stackoverflow.com/questions/23978951/stopping-notification-bar-to-popup-during-game-play

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!