添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement . We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Describe the bug
When the combo box items are different sizes, the popup changes it's width while scrolling wich makes it quite unusable.

To Reproduce
Create a combo that forces to display a scroll, width of different item sizes:

  <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()));