UWP Xbox One page navigation when using WebView

心不动则不痛 提交于 2020-01-15 10:05:01

问题


Usually when running a UWP app on Xbox the B button on the controller is handled automatically and will return you to the previous page.

I have a page which contains a WebView, when you use the directional buttons to place the focus box around that control, the B button no longer responds. You can use the A button to take control of the WebView and display the pointer and the B button then will return focus back as above but I cannot navigate back using the B button until you move the focus box to a different control. This also happens using AdControl since this uses WebView.

I have tried to capture KeyDown:

Window.Current.CoreWindow.KeyDown += CoreWindow_KeyDown;

private void CoreWindow_KeyDown(Windows.UI.Core.CoreWindow sender, Windows.UI.Core.KeyEventArgs args)
{
    Debug.WriteLine(args.VirtualKey.ToString());
}

This responds with GamePadB, GamePadX etc but not when the focus box is around the WebView.

Is there anyway I can find out when the GamePad buttons (specifically B) are pressed when the focus box is around the WebView (or AdControl) and the control isn't engaged so I can manually invoke the backstack navigation?


回答1:


Since this issue happens when using the XY focus mode for the app, if your OS version is 14393 or higher, one workaround for this issue is to use the mouse mode for this page which contains the webview by setting RequiresPointer="WhenFocused" as following:

<Page RequiresPointer="WhenFocused">
...
</Page>

And set another page to XY focus mode by using the following code in the app.xaml.cs:

this.RequiresPointerMode =
   Windows.UI.Xaml.ApplicationRequiresPointerMode.WhenRequested;

For more information, please try to refer to the following article:
https://msdn.microsoft.com/en-us/windows/uwp/input-and-devices/designing-for-tv#mouse-mode



来源:https://stackoverflow.com/questions/41481240/uwp-xbox-one-page-navigation-when-using-webview

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