I have a combobox in WPF that I add items to at run-time (via a data binding to a List). I'd like to set the height of the dropdown box dynamically so that all (or most) of the items show. Unfortunately it seems that the height of the dropdown is set once and cannot be dynamically altered. It always seems to be the same size.
Is there some relatively straightforward to adjust the dropdown height?
Yes, I've tried setting it after adding the items to the combobox. In the debugger it looks like the new value is there. However, when I open the dropdown, it drops down to a size of its own choosing. I've tried exaggerating the MaxDropDownHeight and have even set it to "Auto" to no avail.
The property MaxDropDownHeight
is a dependency property, on the combo box that controls the height of the drop down list. Since it's a dependency property, it's value can be set dynamically.
Have you tried setting this value?
MaxDropDownHeight="Auto"
For me, the issue was that ComboBox dropdown had height of 95 pixels regardles of the amount of items.
My data source for the ComboBox was a Collection<>
, but after changing it to ObservableCollection<>
, the ComboBox dropdown opens showing all items.
Now also the MaxDropDownHeight
property works just fine.
Ref: This comment in here Make the dropdown of a combobox be shorter?
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