<ComboBox SelectedIndex="0">
<ComboBoxItem>Example Item 01</ComboBoxItem>
<ComboBoxItem>Example Item 02</ComboBoxItem>
... etc ...
<ComboBoxItem>Very very very very very very very long item</ComboBoxItem>
<ComboBoxItem>Example Item 25</ComboBoxItem>
<ComboBoxItem>Example Item 26</ComboBoxItem>
... etc ...
</ComboBox>
Expected behavior
The width of the popup should be the max width of the longest item in the combo.
Desktop (please complete the following information):
OS: Windows
Version master latest.
Well, the reason I reported this, is because it was working as expected in 0.10.x
and the default panel for ComboBox
was already a VirtualizingStackPanel
.
So maybe it's worth taking a look.
Avalonia/src/Avalonia.Controls/ComboBox.cs
Line 31
45c009e
Combobox popup width blinks with variable Combobox item sizes
Combobox popup width changes with variable Combobox item sizes
Apr 14, 2023
Well, the reason I reported this, is because it was working as expected in 0.10.x and the default panel for ComboBox was already a VirtualizingStackPanel.
In 0.10 ComboBox wasn't virtualized by default. So it makes sense that it worked before. Now, there is no context information for the combobox to know possible width of unrealized items.
A workaround is to disable virtualization for the ComboBox.
ComboBox result = new ComboBox();
result.ItemsPanel = new FuncTemplate<Panel>(new(() => new StackPanel()));