How can I center a ComboBox's content vertically?

Add VerticalContentAlignment="Center" to your combobox.


If I copy and paste your code, the text is vertically aligned in the center of the ComboBox for me. Are you sure you don't have a Style or Template set up in your application that is applying to your controls and making this happen?

EDIT: Nevermind. I actually had a style set up in my application:

<Style TargetType="{x:Type ComboBox}">
        <Setter Property="VerticalContentAlignment" Value="Center" />
</Style>

So when i copied and pasted your code in, it worked for me!


You have to play with it, but if I had to guess:

 <ComboBox x:Name="cmbPlatform" 
                  Margin="10"
                  FontFamily="Georgia"
                  FontSize="15"
                  MinHeight="30"
                  MinWidth="140"
                  VerticalAlignment="Center"
                  VerticalContentAlignment="Center">

Try changing the MinHeight="30" to a smaller number. It might be you are making the box bigger than the text. The text is centered on the line but the box is bigger.

Tags:

Wpf

Xaml

Combobox