Bug in ComboBox when using VirtualizingStackPanel


  • Hello,

    Scrolling in a ComboBox with a VirtualizingStackPanel does not work when the items do not have the same width and an item is wider than the ComboBox.

    If for example the first item is selected and the first items have a width that's smaller than that of the ComboBox, than when an item with a large width comes into view when scrolling (using the scrollbar or using keys) the combobox scolls back to the first item. So it´s not possible to scroll to the item with a large width or the items after that one.

    Example code:

        <ComboBox x:Name="cb"
              <VirtualizingStackPanel />
      for (int i = 0; i < 25; i++)
      cb.Items.Add("Long string causing the combobox popup to become wider.");
      for (int i = 0; i < 25; i++)
      cb.SelectedIndex = 0;

    Monday, June 21, 2010 9:41 AM


All replies

  • Hi,

    Thanks for reporting the issue. As far as I know, the issue is a known issue.

    Wednesday, June 23, 2010 3:50 AM
  • I've encountered this too, and entered a corresponding bug report:

    Monday, August 16, 2010 12:32 PM
  • Hi,

    I bounced upon the same bug earlier today.
    This is my workaround:
    I specified a fixed width on the VirtualizingStackPanel that is large enough to hold the items.
    If you set the CanHorizontallyScroll to true, a horizontal scrollbar will appear when an item is bigger than the specified width.

    Code snippet:
    <VirtualizingStackPanel Width="250" CanHorizontallyScroll="True">

    Tuesday, October 19, 2010 7:27 AM
  • any update you can offer?

    Thursday, October 27, 2011 1:46 PM