ComboBox的WPF边框
问题描述:
我尝试使用基于ToolBar.ComboBoxStyleKey的ComboBox。它具有平面设计。
控件默认情况下没有边框,即在白色背景上只有ToggleButton的可见图标。
当焦点不在ComboBox上时如何添加边框以进行控制?
I try to use a ComboBox based on ToolBar.ComboBoxStyleKey. It has a flat design. Control by default does not have a border, i.e., on a white background is only visible icon of ToggleButton. How can I add border for control when focus isn't on ComboBox?
谢谢!
没有焦点:
鼠标悬停:
答
WPF中有一个Border控件,您可以使用它来包裹ComboBox。
There is a Border control in WPF, you could use that to wrap around your ComboBox.
<Border Background="GhostWhite" BorderBrush="Gainsboro" BorderThickness="1">
<ComboBox>
...
</CombodBox>
</Border>
http://www.wpf-tutorial.com/misc-controls/the-border-control/
您可以根据组合框是否具有焦点来设置BorderThickness。
You could set the BorderThickness according to if the combobox has the focus or not.