MahApps / MahApps/MahApps.Metro
Feature request: Tab item close handling could be improved to be more mvvm friendly
- Dominant language
- C#
- Stars
- 9.8k
- Forks
- 2.4k
- Avg merge
- 1h 2m
- Merged PRs (30d)
- 56
Description
**Is your feature request related to a problem? Please describe.**
I ran into the same issue as the OP in #2302
While i did find a workaround to link up TabItems in a mvvm friendly way, getting a solution which is async+await friendly is more of an issue.
**Describe the solution you'd like**
Ideally https://github.com/MahApps/MahApps.Metro/blob/71d455826f77d37ad0aa33a922e2b5394406fa52/src/MahApps.Metro/Controls/MetroTabControl.cs#L88 would be `public delegate Task ...`
... so resulting event handlers can be executed asynchronously. That way a viewModel could contain method signatures like `Task TryCloseTabAsync` and do non blocking calls and set the close args onec the async call is done.
The current state is very annoying if you try to delegate close permission handling to the viewModel, since you have to do a blocking call on the viewModel of a tab in the event handler before setting the args to Canceled.
**Closed Issues**
#2302
Contributor guide
Research direction
Start with src/MahApps.Metro/Controls/MetroTabControl.cs at the linked line and review the existing tab-close event and its cancellation arguments. Compare the requested asynchronous delegate shape with the current event handling, then determine how async close permission should complete without blocking. Done means the close flow supports async view-model handlers and preserves cancellation behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- desktop
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100