How to change the width of a WPF combobox dropdown in C #

I'm currently working on a C # WPF project, one thing I can’t do is how do I change the width of the ComboBox drop-down list, because every time I had items, the width of the drop-down list took up the size of the longest item (or line);

How can i fix this? Help other developers / programmers !!!!

+4
source share
1 answer

Set ItemContainerStyle for ComboBoxItem as follows:

 <ComboBox Width="50" Height="40">
        <ComboBox.ItemContainerStyle>
            <Style TargetType="ComboBoxItem">
                <Setter Property="Width" Value="60"/>
            </Style>
        </ComboBox.ItemContainerStyle>
        <ComboBoxItem Content="this is Item One "/>
        <ComboBoxItem Content="this is Item "/>
        <ComboBoxItem Content="this is "/>
        <ComboBoxItem Content="this "/>
    </ComboBox>
+8
source

All Articles