Skip to content

TabControl.SelectedIndex via DialogHost (repo) #3094

@VR462002

Description

@VR462002

Bug explanation

Bug Description

When opening a dialog await DialogHost.Show(view); via MenuItem (System.Windows.Controls) and setting the SelectedIndex of a TabControl by e.g. clicking a button, the selected tab is still the old one after the dialog has been closed.
The property that holds the SelectedIndex receives the new value but instantly switches back to the previous index, which can result in a flicker.

Reproduction

In order to reproduce the bug, please select the second tab (Info). Then click on Menu in the top right corner. Select Settings and click on the button in the dialog.

Debugging

I have found out that it does make a difference whether the dialog is opened via said MenuItem, a PopupBox (Material Design) or a button on any view:
It does work es expected in both of the last two cases, just the MenuItem-way fails.
In order to make it work, insert await Task.Delay(500); (at least 200-300) before setting SelectedIndex to its new value. I'm not a fan of using Task.Delay() but currently out of ideas how to make it work without it.

Using DI does not make a difference in any of the above mentioned behaviors.

Installed NuGet packages:

  • CommunityToolkit.Mvvm (8.1.0)
  • MaterialDesignThemes (4.7.1)
  • Microsoft.Extensions.DependencyInjection (7.0.0)
  • Microsoft.Extensions.Hosting (7.0.1)

Link

GitHub Repository

Version

4.7.1 (latest stable)

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions