I have a menu and a tab control on my WPF gui. I've hidden the tabs from the user so that all pages can only be accessed via menu items or key-shortcuts.
The desired behavior I want is this:
Operator selects 'Help->About' or 'Help->Version History' from my menu and the corresponding tab index for the 'About tab' or 'VersionHistory tab' becomes the 'selected index'.
I'm using MVVM pattern, and currently accomplishing this with a MainTabIndex property that is the go-between: selecting a menu binds to a command which updates the MainTabIndex property, which is bound to the Tab control.
Is there anyway to do this with just XAML? Or a better approach other than using my ViewModel to handle this GUI-only functionality?
My code example, as I've got it now, is listed below:
<TabControl x:Name="MainTabControl" Margin="0,21,0,-25" Background="{x:Null}" BorderBrush="{x:Null}" SelectedIndex="{Binding MainTabIndex, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" TabStripPlacement="Bottom"> ... rest of TabControl deleted for clarity <MenuItem Command="{Binding UpdateDisplayedTab}" Header="_About"><MenuItem.CommandParameter><System:Int32>3</System:Int32></MenuItem.CommandParameter></MenuItem> ... notice I'm passing in the value of 3 to the command, which is the tab index of the 'About' page.