I'm currently working on C# WPF project, one thing I can't seem to do is - How do I change the ComboBox dropdown width, because every time I had Items the dropdown width takes the size of the longest item(or string);
How can I fix this Please Help fellow developers/programmers !!!!
// Set the size of the combobox mybox. Size = new Size(216, 26);
A combobox is a selection control that combines a non-editable textbox and a drop-down listbox that allows users to select an item from a list. It either displays the current selection or is empty if there is no selected item.
Set the ItemContainerStyle of the ComboBoxItem like this:
<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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With