Combobox in toolbar behaves differently

雨燕双飞 提交于 2019-12-08 08:52:17

问题


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.


回答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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!