我想在禁用控件时处理自定义控件的 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/