MahApps / MahApps/MahApps.Metro
Prevent MetroTabItem closing
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 9.8k
- Forks
- 2.4k
- Avg merge
- 1h 2m
- Merged PRs (30d)
- 56
Description
I just got a small question cuz I don't know how to fix it.
I'm using the MetroTabItem controls because they come with a close button "out the box". The content of the tabs is text that can be edited by the user. I want to include a save prompt, when closing the tab without saving the text. But I don't know how to actually "cancel" the closing process. The CanExecute method for the CloseTabCommand is being called when clicking on the close button, but even if I return false, the tab is being closed. I don't know if this is a bug or intended behaviour but regardless, it is quite troublesome.
Anything I can do to prevent the tab from closing?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by inspecting the MetroTabItem close button and the CloseTabCommand, especially how its CanExecute result is handled. Reproduce the editable-tab scenario described in the issue and verify whether returning false from CanExecute prevents the tab from closing.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- desktop
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100