命中测试组合框下拉(从鼠标位置) [英] Hit Test Combobox Dropdown (From mouse location)

查看:88
本文介绍了命中测试组合框下拉(从鼠标位置)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好


我在确定鼠标是否在WPF中的组合框下拉列表中点击时遇到了一些麻烦。

我' m使用鼠标Hook确定鼠标是否在我正在显示的某个窗口之外被点击。这个效果相当不错。


问题是我的一个窗口有一个位于窗口底部的组合框,如果用户点击了一个项目在combobox'下拉列表中,钩子实际上将其视为窗口边界外的点击(这是
的情况)。


现在我已经完成了一些谷歌搜索,发现我正在使用的方法(VisualTreeHelper.HitTest)没有看到组合框'PART_Popup。现在,我如何确定鼠标的位置是否在此控件弹出窗口的范围内? 


我需要一种可以在任何情况下工作的方法,因为我将它用于所有我的对话窗口。


我的另一个选择是制作一个"组合框"。用户控制,如果我需要"下拉",则即时决定上涨或下跌。


非常感谢任何帮助。


谢谢。

A。

解决方案

>> 现在我做了一些谷歌搜索,发现我正在使用的方法(VisualTreeHelper.HitTest)没有看不到
组合框'PART_Popup。现在我如何确定鼠标的位置是否在此控件弹出窗口的范围内?


嗨AntonVDG,


根据您的描述,您想知道鼠标单击是否在Combobox中有效?如果是,您可以在Combobox中单击鼠标后显示Combobox.selectedItem,如果它有值,


这表示它有效。


< pre class ="prettyprint"> private void cmb_SelectionChanged(object sender,SelectionChangedEventArgs e)
{
Console.WriteLine(cmb.SelectedItem.ToString());
}



最好的问候,


Cherry


Hi

I'm having some trouble determining if the mouse has clicked within the bounds of a combobox dropdown in WPF.
I'm using a mouse Hook to determine if the mouse has been clicked outside of a certain window I'm displaying. This works fairly good.

The problem is that one of my windows has a combobox which is positioned at the bottom of the window, and the case is that if the user clicks an item from the combobox' dropdown list, the hook actually sees it as a click outside of the window's bounds (which is the case).

Now i've done some googling and found that the method I am using (VisualTreeHelper.HitTest) doesn't see the combobox' PART_Popup. Now how can I determine if the mouse's location is within the bounds of the popup of this control? 

I need a method that can work in any situation since I use it for all my dialog windows.

My other option is to make a "combobox" user control, and decide on the fly if i need to "drop down" up or down.

Any help would be greatly appreciated.

Thanks.
A.

解决方案

>>Now i've done some googling and found that the method I am using (VisualTreeHelper.HitTest) doesn't see the combobox' PART_Popup. Now how can I determine if the mouse's location is within the bounds of the popup of this control? 

Hi AntonVDG,

According to your description, you want to know if the mouse click is work in Combobox? If yes, you can show Combobox.selectedItem after you mouse click in Combobox, if it is have a value,

this indicates that it is effective.

 private void cmb_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            Console.WriteLine(cmb.SelectedItem.ToString());
        }

Best Regards,

Cherry


这篇关于命中测试组合框下拉(从鼠标位置)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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