I have a View and two View Models. I want to be able to change the displayed tab by changing the SelectedTab variable in the first ViewModel that the TabControl uses as a DataContext by changing the variable in a separate ViewModel that the SelectedTab value is bound to.
Is it failing because I have done something wrong with the OnPropertyChanged command?
The Views tab control XAML
<controls:MetroAnimatedSingleRowTabControl Grid.Row="1" Name="MainTabControl" SelectedIndex="{Binding SelectedTab}" >
The first View Model that contains the SelectedTab binding for the Tab Control.
private String _selectedTab = "0";
public String SelectedTab
{
get { return _selectedTab; }
set
{
_selectedTab = value;
OnPropertyChanged("SelectedTab");
}
}
Code snippet from the second View Model to change the SelectedTab variable.
var tab = new MainViewModel();
tab.SelectedTab = "1";