Wpf combobox padding
It's a simple question
How to remove the space between the contents of a combo box and its border. For instance. If the combobox selection is "Selection 1" then the "S" is drawn at the top-left corner of the ComboBox control with no spaces between it and the top-left of the control.
I did it
<ComboBox Padding="0"/>
Even this:
<ComboBox.ItemContainerStyle>
<Style TargetType="ComboBoxItem">
<Setter Property="Padding" Value="0"/>
</Style>
</ComboBox.ItemContainerStyle>
The above ComboBox is inside a ListView GridViewColumn. Maybe something is messing around with something.
This does not remove padding. Any ideas?
+2
a source to share
2 answers
You can not. At least not with the default template. You will have to write your own. The default template includes the following:
<DockPanel Margin="2">
<TextBox .../>
</DockPanel>
This will be a hard-coded stock. What you can do with the default template is to use negative padding to compensate for the hard-coded margin:
<ComboBox Padding="-2">
<ComboBoxItem >Selected</ComboBoxItem>
</ComboBox>
+2
a source to share