Mouse.DirectlyOver在WPF中返回错误的UIElement [英] Mouse.DirectlyOver returns the wrong UIElement in WPF

查看:140
本文介绍了Mouse.DirectlyOver在WPF中返回错误的UIElement的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

虽然我尝试将鼠标悬停在标签"元素,  Mouse.DirectlyOver,它返回"TextBlock".因此.为什么会这样?

      private void Dynamic_Design_PreviewMouseMove(对象发送方,MouseEventArgs e)
        {
            if(e.LeftButton == MouseButtonState.Pressed)
            {
                  var uiElement = Mouse.DirectlyOver as UIElement;
            }
        }
对此有任何想法吗??


谢谢,
Sowndaiyan

Hi All,

While i try to mouse over on the "Label" element , Mouse.DirectlyOver it returns the "TextBlock" as a result. Why it happen like this?

     private void Dynamic_Design_PreviewMouseMove(object sender, MouseEventArgs e)
        {
            if(e.LeftButton == MouseButtonState.Pressed)
            {
                 var uiElement = Mouse.DirectlyOver as UIElement;
            }
        }
Any idea on this..?


Thanks,
Sowndaiyan

推荐答案

标签几乎是TextBlock的包装,它解释了为什么返回TextBlock.
A label is pretty much a wrapper for a TextBlock which explains why you have TextBlock returned.


这篇关于Mouse.DirectlyOver在WPF中返回错误的UIElement的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆