我想将 wpf 中的光标更改为自定义 .cur 文件?

发布于 2024-12-21 05:31:07 字数 107 浏览 1 评论 0原文

我想将鼠标指针更改为应用程序中的自定义光标。

因此,当我的应用程序启动时,我想要自定义光标,当它停止时,我希望它消失。

如何在 wpf 代码后面的 c# 中执行此操作?

I want to change my mouse pointer to an custom cursor in my application.

So when my application starts, i want the custom cursor, and when it stops i want it gone.

How to do this in c# behind the code in wpf?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

燕归巢 2024-12-28 05:31:07

你可以这样实现。简单的步骤。只需提供 .cur 图像路径并将其与 Cursor 绑定即可。

<Window>
    <Window.Resources>
        <Cursor x:Key="OpenHandCursor">C:\Users\Images\InvalidS.cur</Cursor>
    </Window.Resources>

    <StackPanel Cursor="{StaticResource OpenHandCursor}">

    </StackPanel>
</Window>

谢谢

You Can implement it this way. Simple steps. Just have to give the .cur image path and bind it with Cursor.

<Window>
    <Window.Resources>
        <Cursor x:Key="OpenHandCursor">C:\Users\Images\InvalidS.cur</Cursor>
    </Window.Resources>

    <StackPanel Cursor="{StaticResource OpenHandCursor}">

    </StackPanel>
</Window>

Thank You

当梦初醒 2024-12-28 05:31:07

您无法更改整个操作系统环境的光标,只能更改 WPF 窗口。

按照这篇文章了解如何设置自定义光标

You can not have the cursor changed for the whole operating system environment, only the WPF window.

Follow this post on how to set a custom cursor

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文