gpt4 book ai didi

wpf - 如何在 XAML/WPF 中设置鼠标光标?

转载 作者:行者123 更新时间:2023-12-05 00:41:18 24 4
gpt4 key购买 nike

如何在 xaml 中设置鼠标光标?

Cursor 属性在每个控件中的用途是什么?请不要回答为 Cursor="Arrow" 因为这不起作用。

我现在唯一能做到的方法是从后面的代码 Mouse.OverrideCursor。我可以简单地使用 XMAL 吗?

我有一个控件层次结构,其中某处之间有一个 GridSplitter。我正在尝试将光标设置为 SizeNS,但它被设置为默认的默认 Arrow。我该怎么办?

最佳答案

在 WPF 中,Cursor 在层次结构中声明控件并且属性被覆盖时会产生问题。

如果您想在控件中设置 Cursor,请使用 FrameworkElement 类的 ForceCursor 属性。

语法:

    <StackPanel Name="CursorForced" ForceCursor="true" Cursor="Hand">
<Label>Cursors Forced</Label>
<TextBox>Fill me in!</TextBox>
</StackPanel>

In above example if I don't use ForceCursor the Cursor will be different over TextBox not as I defined in parent control.

MSDN link to How to Force Cursor

关于wpf - 如何在 XAML/WPF 中设置鼠标光标?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35311116/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com