MahApps / MahApps.Metro

A framework that allows developers to cobble together a better UI for their own WPF applications with minimal effort.
https://mahapps.com
MIT License
9.2k stars 2.45k forks source link

Feature request: Tab item close handling could be improved to be more mvvm friendly #3714

Open taori opened 4 years ago

taori commented 4 years ago

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

timunie commented 4 years ago

Hi @taori

As long as this feature is not integrated here, you may try using Dragablz. I think they support what you want and they integrate with MahApps. https://github.com/ButchersBoy/Dragablz

Happy coding Tim