工具栏中的Combobox行为不同 [英] Combobox in toolbar behaves differently

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

问题描述

this 主题开始提出新问题,任何人都可以回答为什么 ComboBox CheckBox es在工具栏内外会有不同的行为?



来自链接问题的摘要:



我注意到,当ComboBox放置在工具栏中时,会有不同的行为。当不在工具栏中时,它的行为如预期的:复选框更改状态,而不关闭弹出窗口。但在ToolBar中,弹出窗口会在第一次点击时关闭,而不管点击在哪里。请尝试新的代码。我真的需要这个工具栏。

解决方案

我想感谢jberger建议我去MS。 >

,解决方案是将 CheckBox.Focusable 属性设置为 False

 < DataTemplate DataType =MyDataClass> 
< CheckBox Focusable =False... />
< TextBlock ... />
< / DataTemplate>

这提供了 ComboBox 是在工具栏或只是漂浮在一些面板


Starting a new question from this thread, Can anyone answer why a ComboBox with CheckBoxes would behave differently inside and outside of a toolbar?

Summary from linked question:

I noticed that there is a difference of behavior when the ComboBox is placed in a Toolbar. When not in the Toolbar, it behaves as expected: the CheckBox changes state without closing the Popup. But in the ToolBar, the Popup closes on the first click, regardless of where the click is. Try the new code, please. I really need this in a toolbar.

解决方案

I'd like to thank jberger for suggesting I go to MS.

As suggested by MS, the solution is to set the CheckBox.Focusable property to False in the template.

    <DataTemplate DataType="MyDataClass">
        <CheckBox Focusable="False" ... />
        <TextBlock ... />
    </DataTemplate>

This provides the desired behavior when the ComboBox is either in a ToolBar or just floating in some Panel.

这篇关于工具栏中的Combobox行为不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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