问题
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:
- Set your application as full screen
- 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