This article describes how to programmatically close TabItem through button click in MVVM pattern.
TabItemExt can be closed programmatically by passing SelectedIndex as a parameter to RemoveAt method of Collection Class to remove the TabItem at the specified position from tab collection in view model. Adding command and command parameter on the button to close the TabitemExt in a button click in MVVM.
Added a Command binding for closing the TabItem in TabControlExt. By Binding ElementName and Path of TabControlExt as a CommandParameter to a button in order to close the selected TabItem in the view model.
The following code example demonstrates the same.
The output for the above code is shown below:
|Article ID:||Published Date:||Last Revised Date:||Platform:||Control:|