WindowsPhone8.1和Win10常用的API

1. APP打开后保持屏幕唤醒,不进入休眠

在OnNavigatedTo中加:

DisplayRequest displayRequest = new DisplayRequest();
displayRequest.RequestActive();

2. App全屏:

a. 隐藏Status Bar

await Windows.UI.ViewManagement.StatusBar.GetForCurrentView().HideAsync();

b. 隐藏下面虚拟导航键

Windows.UI.ViewManagement.ApplicationView.GetForCurrentView().SuppressSystemOverlays = true;

3. 处理Windows Phone的Back键消息

protected override void OnNavigatedTo(NavigationEventArgs e)
{
    if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons"))
        HardwareButtons.BackPressed += HardwareButtons_BackPressed;         
}

protected override void OnNavigatedFrom(NavigationEventArgs e)
{
    if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons"))
        HardwareButtons.BackPressed -= HardwareButtons_BackPressed;
    base.OnNavigatedFrom(e);
}

private void HardwareButtons_BackPressed(object sender, BackPressedEventArgs e)
{
    e.Handled = true;//按Back无反应
  //Application.Current.Exit(); //退出程序 }

 

posted @ 2015-11-10 11:48  Kunkka_An  阅读(796)  评论(0编辑  收藏  举报