This code works fine :
<sdk:DataGrid ItemsSource="{Binding MyItems}" SelectedItem="{Binding MySelectedItem,Mode=TwoWay}" x:Name="dataGrid">
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<i:InvokeCommandAction Command="{Binding CommandName}" CommandParameter="{Binding ElementName=MainTabControl,Mode=OneWay}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
In my CustomDataGrid the Command executes but the CommandParameter is null :
<customControl:CustomDataGrid ItemsSource="{Binding MyItems}" SelectedItem="{Binding MySelectedItem,Mode=TwoWay}" x:Name="dataGrid">
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<i:InvokeCommandAction Command="{Binding CommandName}" CommandParameter="{Binding ElementName=MainTabControl,Mode=OneWay}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
EDIT:
My CustomDataGrid is driven from standard DataGrid and add an Event to it. it overrides two event: OnLoadingRow and OnUnLoadingRow.
Note that a simple CommandParameter e.g. a simple string was sent fine.
And MainTabControl is:
<sdk:TabControl Name="MainTabControl"> ...
What is the problem?
OK, I have built a complete mockup of your situation and provided all code below. Everything is bare-bones, so everyone please ease up on the number of bad practices I put in it 🙂
The bad new is, that my derived class works exactly the same as the normal DataGrid! When the command breakpoint is hit with the derived grid the parameter is exactly the same TabControl type.
To take this further I would need to see what else you may be doing (in addition what you have already mentioned). Feel free to contact me through my website if you do not want to make your code public.
View:
Code-behind:
ViewModel:
Custom datagrid: