In the MVVM demo app by Josh Smith, When you attempt to close a tab via the close button on that tab (which is not the currently selected tab), then it will not close, instead it closes the selected tab.
How can I amend the code so that when I click on the close button for a tab item that not the currently selected one, it closes the right tab?
Note, I have tried using AttachedProperties
and the following:
AttachedCommand:CommandBehavior.Event="Click"
AttachedCommand:CommandBehavior.Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.CloseWorkspaceCommand}"
AttachedCommand:CommandBehavior.CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext}"
where I pass in the CommandParameter
, but this gets the ViewModel of the hosting View and not the View Model bound to the ContentPresenter
.
Thanks for your time.