简体   繁体   English

如何在UWP应用程序中将鼠标光标设置为隐藏?

[英]How to set the mouse cursor to hidden in a UWP application?

In a C# UWP application I use Window.Current.CoreWindow.PointerCursor = null to try and set the mouse cursor to stop rendering which used to work a few windows 10 updates ago but recently the cursor no longer disappears. 在C#UWP应用程序中,我使用Window.Current.CoreWindow.PointerCursor = null尝试设置鼠标光标以停止渲染,该鼠标光标曾经在10之前更新过一些Windows,但是最近不再消失。

What is the correct method to remove the rendering of the cursor? 删除游标呈现的正确方法是什么?

Also I have tried running the code both in and outside a Window.Current.CoreWindow.Dispatcher.RunAsync method. 我也尝试在Window.Current.CoreWindow.Dispatcher.RunAsync方法的内部和外部运行代码。

And I have verified that Window.Current.CoreWindow.PointerCursor is null after I set it. 并且我已经验证了Window.Current.CoreWindow.PointerCursor设置为空后。

您需要在App构造函数中编写以下代码

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM