ComboBox的WPF边框 [英] WPF Border for ComboBox

查看:365
本文介绍了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.

这篇关于ComboBox的WPF边框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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