I have a UserControl
, defined like so:
<UserControl x:Name=userControlName>
<UserControl.Resources>
<Style TargetType="{x:Type MyControl}">
<Setter Property="ContextMenu">
<Setter.Value>
<ContextMenu >
<MenuItem Header="ITEM"
Command="{Binding ElementName=userControlName, Path=DeleteCommand">
</MenuItem>
</ContextMenu>
</Setter.Value>
</Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type controlType}">
<Grid>
<!--MyContentHere-->
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</UserControl.Resources>
<Grid>
<!--Content -->
<ListBox>
<ListBoxItem> <!--is of Type MyControl-->
</ListBox>
</Grid>
</UserControl>
This does not work, as the userControlName's DataContext
is not being found.
Am I missing something here?