UWP APP使用Xbox控制器代替鼠标

时间:2018-11-19 15:16:29

标签: c# uwp

我有一个带有mediaPlayerElement和WebView Javascript中的WebView的C#应用​​程序 我设置

window.navigator.gamepadInputEmulation = 'keyboard';

并在我设置的C#构造函数中

public MainPage()
    {
        this.InitializeComponent();
        this.RequiresPointer = RequiresPointer.Never;
        Loaded += MainPage_Loaded;
    }

但是,一旦启动媒体播放器,就会显示一个光标,当媒体播放器关闭时,光标仍然存在,并且我无法再使用xbox控制器浏览该应用程序。 Xaml以下

    <Page
        x:Class="App19.MainPage"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="using:App19"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d"
        Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
    <Grid>
        <MediaPlayerElement
            x:Name="media"
            KeyUp="Media_KeyUp"
            Stretch="Fill"
            Width="1300" 
            AutoPlay="True"
            RequiresPointer="Never"
            reTransportControlsEnabled="True" />
        <WebView 
            x:Name="MyWebView" DefaultBackgroundColor="Transparent" 
          NavigationStarting ="webView_NavigationStarting" ScriptNotify = 
       "MyWebView_ScriptNotify" />  
    </Grid>

</Page>

我想在整个应用程序中禁用鼠标光标。有知道我该怎么做吗?

1 个答案:

答案 0 :(得分:2)

要关闭鼠标模式,请将以下内容添加到应用程序的构造函数中:

public App() 
{
    this.InitializeComponent();
    this.RequiresPointerMode = 
    Windows.UI.Xaml.ApplicationRequiresPointerMode.WhenRequested;
    this.Suspending += OnSuspending;
}

取自MSDN

相关问题