Open eugenegff opened 5 years ago
Thank you for opening this issues @eugenegff ! I think this is a reasonable request. One clarifying question - would it be beneficial to have CloseRequestedCommand (or whatever we call it) on both TabView and TabViewItem? Or does it only need to be on one or the other?
I think it would be inconvenient to have it on TabView, as there are no context, which tab is closing. On the other hand, for TabViewItem the item is DataContext, so everything is possible. Therefore I do not see much value in having it in TabView or both places - only in TabViewItem.
Much more interesting would be to react on CanExecute to use it together/instead of TabViewItem::IsClosable. Probably tab should be closable if IsClosable && (!closeCmd || closeCmd->CanExecute(closeCmdParam))
Proposal: Add CloseCommand for TabViewItem for MVVM scenarios
Summary
TabView has TabItems property and AddTabButtonClick, TabCloseRequested events to facilitate tabs enumeration/adding/closing. For MVVM scenarios there are bindable properties TabItemsSource, AddTabButtonCommand, AddTabButtonCommandParameter, but there are no CloseCommand nor any other MVVM compatible way to close tab. Writing code instead of such binding is complicated if UI is decoupled from Model layer, quite possibly living in different DLLs that are not depended on each other
Rationale
Scope
Important Notes
Open Questions