Google喜欢Silverlight中的SearchBox [英] Google like SearchBox in Silverlight

查看:107
本文介绍了Google喜欢Silverlight中的SearchBox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在Silverlight中创建了一个Google的SearchBox控件。这意味着,当我在框中输入时,DropDownListBox出现在SearchBox的正下方,显示与我在searchbox中键入的文本(即AutoComplete功能)匹配的所有项目,就像这样:





现在,我想添加一个功能:我想让DropDownListBox消失,一旦用户点击外面,或屏幕上的任何地方。在其他控件中,我无法处理 MouseLeftButtonDown (或任何这样的事件),因为用户可以点击任何地方,包括非银光区域。任何人都可以建议我该怎么做才能实现这一目标?



所以我的问题基本是:



如何知道用户是否刚刚点击,点击事件发生在特定控件之外?



请注意, AutoCompleteBox 不符合我的目的。所以我不能使用它。

解决方案

我有一种感觉,使用 LostFocus 事件可以解决你的问题。


I've created a Google like SearchBox control in Silverlight. That means, as I type in the box, a DropDownListBox appears just below the SearchBox, showing all the items that match with the text I've typed in searchbox so far (i.e AutoComplete feature), exactly like this:

Now, I want to add a functionality to it : I want to make the DropDownListBox to disappear, as soon as user clicks outside it, or anywhere on the screen. I cannot handle MouseLeftButtonDown (or any such event) in other controls, to accomplish this, because users can click anywhere, including non-silverlight region. Can anybody suggest me what should I do to achieve this?

So my question basically is:

How to know if user has just clicked and the click event occurred outside a particular control?

Please note that AutoCompleteBox doesn't serve my purpose. So I cannot use it.

解决方案

I have a feeling that working with LostFocus event can solve your problem.

这篇关于Google喜欢Silverlight中的SearchBox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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