uwp - 在 UWP 应用中更改鼠标指针

标签 uwp mouse-pointer

是否可以在 UWP 应用中更改甚至隐藏鼠标指针?
我唯一能找到的是:

Windows.UI.Xaml.Window.Current.CoreWindow.PointerCursor = null;

但是在 UWP 中,这不起作用。

最佳答案

不,这不可能隐藏光标,但您可以使用其他图标,例如:

  • 箭头
  • 十字
  • 定制
  • 帮助
  • IBeam

  • 使用 xaml 按钮并添加 PointerEntered按钮控件内的事件,如:
    <Button Name="button"  BorderThickness="2" PointerEntered="button_PointerEntered"  PointerExited="button_PointerExited">Button</Button>
    

    和 C# 代码:
     private void button_PointerEntered(object sender, PointerRoutedEventArgs e)
        {
            Windows.UI.Xaml.Window.Current.CoreWindow.PointerCursor = new Windows.UI.Core.CoreCursor(Windows.UI.Core.CoreCursorType.Hand, 1);
        }
        private void button_PointerExited(object sender, PointerRoutedEventArgs e)
        {
            Windows.UI.Xaml.Window.Current.CoreWindow.PointerCursor = new Windows.UI.Core.CoreCursor(Windows.UI.Core.CoreCursorType.Arrow, 1);
        }
    

    关于uwp - 在 UWP 应用中更改鼠标指针,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37956628/

    相关文章:

    c# - 如何在 UWP 的 StackPanel 中使用 ContextFlyout?

    c# - UWP Entity Framework Core SQLITE 在 Release模式下崩溃

    c# - 如何更改 Windows 10 UWP 应用中根框架导航的页面名称?

    c# - UWP AutoSuggestBox SuggestionChosen 在通过键盘向上/向下选择第一项时触发

    C# UWP - OnNavigedTo 触发方法两次

    windows - Windows 7中I型光标的热点不正确?