问题描述
从主题开始提出新问题,任何人都可以回答为什么 ComboBox
与 CheckBox
es在工具栏内外会有不同的行为?
来自链接问题的摘要:
我注意到,当ComboBox放置在工具栏中时,会有不同的行为。当不在工具栏中时,它的行为如预期的:复选框更改状态,而不关闭弹出窗口。但在ToolBar中,弹出窗口会在第一次点击时关闭,而不管点击在哪里。请尝试新的代码。我真的需要这个工具栏。
我想感谢jberger建议我去MS。 >
如,解决方案是将 CheckBox.Focusable
属性设置为 False $ c $
< DataTemplate DataType =MyDataClass>
< CheckBox Focusable =False... />
< TextBlock ... />
< / DataTemplate>
这提供了 ComboBox
是在工具栏
或只是漂浮在一些面板
。
Starting a new question from this thread, Can anyone answer why a ComboBox
with CheckBox
es 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行为不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!