dotnet / dotnet/wpf

ComboBox doesn't update the popup's content if it was resized during the update

Open
#10,966 2 comments 2 reactions 0 assignees View on GitHub
Investigate
Dominant language
C#
Stars
7.7k
Forks
1.3k
Avg merge
1d 11h
Merged PRs (30d)
61

Description

Reproduction steps:
1. `git clone https://github.com/vers-one/wpf-combobox-issue-reproduction`
2. Open `Source\ComboBoxIssueReproduction.sln` project in Visual Studio 2022.
3. Build and run the project.

You will see the following window:

Image

Follow the steps listed in the window.

If you **don't** check the "Resize combo box" check box, you will see two items in the combo box after clicking the button:

Image

However, if you had the check box checked, there will be only one item in the combo box:

Image

Even though the second item is not visible in the popup, you can still access it via the arrow keys and pressing Enter to select it:

Image

Without the Fluent theme, the issue is not reproducible:

Image

Code of the reproduction app for reference:

`MainWindow.xaml`:
```xaml





























```

`MainWindow.xaml.cs`:
```cs
using System.Collections.ObjectModel;
using System.Windows;

namespace ComboBoxIssueReproduction
{
public partial class MainWindow : Window
{
private readonly ObservableCollection items = [];

public MainWindow()
{
InitializeComponent();
comboBox.Width = 250;
items.Add("Item 1");
comboBox.ItemsSource = items;
comboBox.SelectedIndex = 0;
}

private void Button_Click(object sender, RoutedEventArgs e)
{
if (resizeCheckBox.IsChecked == true)
{
comboBox.Width -= 10;
}
items.Add("Item 2");
}
}
}
```

Contributor guide

Open the contributing guide

Research direction

Start by running the linked reproduction using MainWindow.xaml and MainWindow.xaml.cs in Visual Studio 2022, comparing the Fluent and non-Fluent themes. Trace the ComboBox popup update when Button_Click changes the width and adds Item 2; done means both items are visible after reopening the Fluent-themed combo box.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
desktop
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.