gpt4 book ai didi

c# - WPF:当 IsEnabled=false 时获取 MouseEnter 事件

转载 作者:太空狗 更新时间:2023-10-29 23:00:41 25 4
gpt4 key购买 nike

我想在禁用控件时处理自定义控件的 MouseEnter 事件。有办法处理吗?

最佳答案

UIElement.IsEnabled 的文档记录您看到的行为:

Elements that are not enabled do not participate in hit testing or focus and therefore will not be sources of input events.

对我来说,合乎逻辑的结论是,如果您确实想要处理鼠标事件,则不要禁用该控件。相反,使用其他方法来实现您想要的。例如,如果它是一个输入控件,将其设置为只读而不是禁用可能就足够了。你的问题并没有真正解释你为什么想要这个,所以我无法猜测适合你的方法是什么。

关于c# - WPF:当 IsEnabled=false 时获取 MouseEnter 事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14187468/

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