I have the following Layout:
public class ParentUserControl : UserControl{...}
<ParentNameSpace:ParentUserControl
...
DataContext={Binding MyViewModel ....}
>
<TreeView ...>
<HierarchicalDataTemplate
.... >
<StackPanel>
<StackPanel.ContextMenu>
<ContextMenu>
<MenuItem Header="item"
Command="{Binding DataContext.SomeCommandInMyViewModel,
RelativeSource={RelativeSource
AncestorType={x:Type ParentUserControl}}}"/>
</ContextMenu>
</StackPanel.ContextMenu>
<TextBlock Text="{Binding Path=Name}"/>
</StackPanel>
</HierarchicalDataTemplate>
</TreeView>
Im trying to call a command of the UserControls ViewModel from within the Context of a TreeViewItem with no success. It tells me ParentUserControl Is not supported in a wpf Project. If I change AncestorType to UserControl the Command does not get called. Is there something I miss?