MahApps / MahApps/MahApps.Metro

Prevent MetroTabItem closing

Open
#4,078 4 comments 0 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.