问题
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.
回答1:
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
.
来源:https://stackoverflow.com/questions/8214948/combobox-in-toolbar-behaves-differently