David Bentley
David Bentley

Reputation: 864

c# WPF Combobox selected item text cut off

enter image description here

Not sure where in the combobox style I can fix this. If you need me to post code let me know, but the style code is pretty long. Below is the combobox less the style.

                    <ComboBox x:Name="user_combobox" Margin="115,62,0,0" Height="26" Width="306"
                              HorizontalAlignment="Left" VerticalAlignment="Top" 
                              IsReadOnly="True"
                              Foreground="White" Background="SteelBlue" BorderBrush="White" OpacityMask="RoyalBlue"
                              Style="{StaticResource ComboBoxFlatStyle}"
                              ItemContainerStyle="{StaticResource ComboBoxItemFlatStyle}"
                              MaxDropDownHeight="{Binding User_Combobox_Height}"
                              ItemsSource="{Binding Username_List}">

                        <ComboBox.Resources>
                            <SolidColorBrush x:Key="ComboBoxHighlightBrush" Color="RoyalBlue" />
                        </ComboBox.Resources>

                        <ComboBox.ItemTemplate>
                            <DataTemplate>
                                <TextBlock Text="{Binding Path=username}" Margin="0,-1,0,1" Height="22" FontSize="16" FontWeight="Bold" />
                            </DataTemplate>
                        </ComboBox.ItemTemplate>

                    </ComboBox>

Upvotes: 0

Views: 1821

Answers (2)

BNB
BNB

Reputation: 21

I know, this answer is pretty old, but in case anyone faces the same issue again:

I had the same exact problem. I solved it thanks to the answer of Roger Leblanc. Changing widths and heights didn't change anything. But adding a Padding of 0 (or higher) solved it.

Upvotes: 0

Roger Leblanc
Roger Leblanc

Reputation: 1583

A wild guess, but is it possible that in your "ComboBoxFlatStyle" Style, you're setting a value for Template property of the ComboBox? If so, check your Margin value for any Control you've set there, you probably have some top or bottom margin that are too restrictive.

Upvotes: 2

Related Questions