tags:

views:

141

answers:

2

This is a simple question

How do you remove the space between the content of a combobox and the border of it. E.g. If the selection of a combobox is "Selection 1" then the "S" is drawn at the very top left of the ComboBox control with no whitespace spacing between it and top left portion of the control.

I did this

<ComboBox Padding="0"/>

Even this:

<ComboBox.ItemContainerStyle>
  <Style TargetType="ComboBoxItem">
    <Setter Property="Padding" Value="0"/>
  </Style>
</ComboBox.ItemContainerStyle>

The specified ComboBox above is within a ListView GridViewColumn. Maybe that's messing with something.

This doesn't remove the padding. Any ideas?

+1  A: 

You can't. At least, not with the default template. You'd have to write your own. The default template includes this:

<DockPanel Margin="2">
    <TextBox .../>
</DockPanel>

That'll be a hard-coded margin. About the best you could do with the default template is use a negative padding to offset the hard-coded margin:

<ComboBox Padding="-2">
    <ComboBoxItem >Selected</ComboBoxItem>
</ComboBox>

HTH,
Kent

Kent Boogaart
+1  A: 

In Expression Blend this is trivial:

  1. Right-click the ComboBox and select Edit Control Parts (Template) - Edit A Copy.
  2. Remove the Margin="2" from the beginning of the template.
Ray Burns