Reputation: 153
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?
Thanks!
No focus:
Mouse hover:
Upvotes: 1
Views: 5529
Reputation: 967
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/
You could set the BorderThickness according to if the combobox has the focus or not.
Upvotes: 1
Reputation: 2440
There are countless options available.
Draw a rectangle around the combobox's (x,y) coordinates.
Make your own custom combobox as shown in: CustomCombowithBorder.
Add a panel behind it and give the panel a border thus imitating a border.
etc....
EDIT:
Found that MSDN gives an excellent answer as also shown in ComboBox Styling .
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ComboBox">
<Grid>
<Border x:Name="ContentPresenterBorder">
<Grid>
<ToggleButton x:Name="DropDownToggle"/>
<ContentPresenter x:Name="ContentPresenter" />
<TextBlock Text=" " />
</ContentPresenter>
</Grid>
</Border>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
Upvotes: 0