MahApps / MahApps/MahApps.Metro
HamburgerMenu's SelectedItem issues with IsAsync=True
- Dominant language
- C#
- Stars
- 9.8k
- Forks
- 2.4k
- Avg merge
- 1h 2m
- Merged PRs (30d)
- 56
Description
**Describe the bug**
Since the hamburger menu changes in 2.0.0 (https://github.com/MahApps/MahApps.Metro/commit/80c6fb4ae77331662f18139ffc09a98a8d0b0083) my menu items no work correctly with an async binding, e.g.
`SelectedItem="{Binding SelectedMenuItem, Mode=TwoWay, IsAsync=True}"`. Sometimes there are like 30 clicks needed for the SelectedItem to have the new value. It does seem to work without IsAsync.
**To Reproduce**
If you use the official demo app and make this change in HamburgerMenuDefault.xaml:
```xaml
```
Inside MainWindowViewModel add:
```csharp
public HamburgerMenuGlyphItem SelectedHamburgerItem
{
get => this.selectedHamburgerItem;
set
{
if (Equals(value, this.selectedHamburgerItem)) return;
this.selectedHamburgerItem = value;
this.OnPropertyChanged();
}
}
```
Then go to the hamburger menu and try clicking through the images. You'll notice that only the first one ever gets opened. See this gif: https://i.imgur.com/AEd6XWz.gifv You don't see the clicks but they're there. This only happened since these hamburger changes, it worked fine earlier.
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
See this gif: https://i.imgur.com/AEd6XWz.gifv
**Environment(please complete the following information):**
- MahApps.Metro version 2.0.0-alpha0302+
- OS: All
- Visual Studio 2019
- .NET Framework 4.7.2
**Additional context**
This is a based on the comments in https://github.com/MahApps/MahApps.Metro/commit/80c6fb4ae77331662f18139ffc09a98a8d0b0083. Thought it might be easier to track through an issue.
Contributor guide
Research direction
Start with the official demo app's HamburgerMenuDefault.xaml and MainWindowViewModel, applying the shown IsAsync=True SelectedItem binding and property. Run the demo and click through the hamburger images to reproduce the selection failure. Done means each click updates and opens the selected item reliably when asynchronous binding is enabled.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- desktop, frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100