I have a WPF application and in the main window I have a TabControl.
I would like the TabItems to fire a RelayCommand that I have in my ViewModel when they get selected (different commands for each TabItem).
I don't want a TabItem to be selected for some conditions that are set in the commands CanExecute function.
Is this possible? 
I think the right way to go here is not 'ICommand' but just a ViewModel property which will twoway bind to the TabControl.SelectedIndex (or SelectedItem) then you can take the decision in the ViewModel. This is better than defining a lot of commands specific to each TabItem
<TabControl SelectedIndex="{Binding VMSelectedTabIndex, Mode=TwoWay}">
//OR
<TabControl SelectedItem="{Binding VMSelectedItem, Mode=TwoWay}">
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With