当 IsHitTestVisible 为 false 时,允许点击 ComboBoxItem 中的 Button [英] allowing clicks on Button in ComboBoxItem when IsHitTestVisible is false

查看:26
本文介绍了当 IsHitTestVisible 为 false 时,允许点击 ComboBoxItem 中的 Button的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

替代文字 http://img375.imageshack.us/img375/9830/combobox.png

设置 IsHitTestVisible="false" 会使整个 ComboBox 的放置区域对点击无响应.设置为 true 也是如此.

Setting the IsHitTestVisible="false" has the effect of having the whole ComboBox's drop area unresponsive to clicks. The same goes for setting to true.

使用 ComboBox 我不需要创建任何故事板来制作 ComboBox 动画,但我发现了这个问题.

With a ComboBox I don't have to create any storyboard to make ComboBox animation like but I found this issue.

如何让 ComboBoxItem 区域除了里面的按钮之外无法点击?

How can one make the ComboBoxItem area unclickable except for the button within?

推荐答案

听起来你应该创建一个使用弹出窗口的自定义控件,它看起来像一个组合框,但是你可以做你想做的:

Sounds like you should be creating a custom control that uses a popup window, that just looks like a combobox, however you can do what you wanted:

  • 将您的按钮放在一个网格内,在一个 RadComboBoxItem 内
  • 将网格背景颜色设置为 1% alpha,使其在命中测试中可见但不可见
  • 向网格添加 Grid_MouseLeftButtonUp 事件处理程序
  • 在处理程序中将 e.Handled 设置为 true,这样鼠标就被吃掉了

确保在按下按钮时关闭组合框弹出窗口.

Make sure you close the combobox popup when you get your button presses.

希望这会有所帮助.

这篇关于当 IsHitTestVisible 为 false 时,允许点击 ComboBoxItem 中的 Button的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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