I have a screen that looks like this:

Each colored area is a different UserControl put into the MainView.xaml as follows:
<UserControl Name="TopDockPanel" DockPanel.Dock="Top" Content="{Binding QuickInfoVM, Source={StaticResource Locator}}" />
<UserControl Name="LeftDockPanel" DockPanel.Dock="Left" Content="{Binding NavigationVM, Source={StaticResource Locator}}" />
<UserControl Name="RightDockPanel" DockPanel.Dock="Right" Content="{Binding MainContentVM, Source={StaticResource Locator}}" />
(I am using MVVMLight so Locator is the ViewModelLocator)
The green area is an ItemsControl area displaying buttons for each of the items (Company & Employee):
<UserControl x:Class="MvvmLightDemo.View.NavigationView"
Name="Navigation"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:MvvmLightDemo.View"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="120"
DataContext="{Binding MainContentVM, Source={StaticResource Locator}}" >
<StackPanel Background="CadetBlue">
<ItemsControl ItemsSource="{Binding PageViewModels}">
<ItemsControl.ItemTemplate>
<ItemContainerTemplate>
<Button Content="{Binding Name}"
Style="{StaticResource NavigationTextStyle}"
Command="{Binding ChangePageCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:NavigationView}}}" />
</ItemContainerTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</StackPanel>
</UserControl>
The MainContentVM contains the ChangePageCommand as follows:
public RelayCommand<IPageViewModel> ChangePageCommand
{
get
{
return _changePageCommand = new RelayCommand<IPageViewModel>(
p => ChangeViewModel((IPageViewModel)p),
p => p is IPageViewModel);
}
}
My question is, how do I bind the Buttons in the ItemContainerTemplate to the ChangePageCommand in MainContentVM? What I have doesn't work, when debugging the ChangePageCommand is never called when clicking either button.
When I use Command="{Binding ChangePageCommand, RelativeSource={RelativeSource AncestorType={x:Type local:NavigationView}}}" shouldn't that set the binding of the Command to that of the NavigationView (DataContext = MainContentVM)?