Q:

Binding Contextmenu

 <ItemsControl ItemsSource="{Binding ViewModelOne.Items}">
        <ItemsControl.ItemsPanel>
            <ItemsPanelTemplate>
                <Canvas/>
            </ItemsPanelTemplate>
        </ItemsControl.ItemsPanel>
        <ItemsControl.ItemContainerStyle>
            <Style>
                <Setter Property="Canvas.Left" Value="{Binding X}"/>
                <Setter Property="Canvas.Top" Value="{Binding Y}"/>
            </Style>
        </ItemsControl.ItemContainerStyle>
        <ItemsControl.ItemTemplate>
            <DataTemplate >
                <ContentControl>
                      <StackPanel Orientation="Vertical">
                             <StackPanel.ContextMenu>
                                <ContextMenu >
                                <MenuItem Header="Delete" Command="{Binding ViewModelOne.DeleteCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type local:MainWindow}}}" />
                                </ContextMenu>
                            </StackPanel.ContextMenu>
                            <TextBlock x:Name="Details" Text="{Binding Details}" />
                            <TextBlock x:Name="Name" Text="{Binding Name}" />
                            <Rectangle x:Name="Rects" Height="10" Width="10" Stroke="Black" StrokeThickness="1" />
                        </StackPanel>
                </ContentControl>
            </DataTemplate>
        </ItemsControl.ItemTemplate>
    </ItemsControl>

I have the above part of the code in my project and am trying to bind the Contextmenu command, what is the correct way.
I have also tried  
 <MenuItem Header="Delete" Command="{Binding PlacementTarget.Tag.DeleteCommand, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=ContextMenu}}"  />

Still i couldnot get the command working 

A:

Instead of putting ContextMenu on the your StackPanel, set ContextMenu on your Item in ItemContainerStyle and also set the Tag for the Item to the parents DataContext. 
 <ItemsControl x:Name="MyItemControl" ItemsSource="{Binding ViewModelOne.Items}">
     <ItemsControl.ItemContainerStyle>
                <Style TargetType="ContentPresenter">
                    <Setter Property="Tag" Value="{Binding DataContext, ElementName=MyItemControl}"></Setter>
                    <Setter Property="ContextMenu">
                        <Setter.Value>
                            <ContextMenu >
                                <MenuItem Header="Delete" Command="{Binding PlacementTarget.Tag.ViewModelOne.DeleteCommand, RelativeSource={RelativeSource Self}}" />
                            </ContextMenu>
                        </Setter.Value>
                    </Setter>
                    <Setter Property="Canvas.Left" Value="{Binding X}"/>
                    <Setter Property="Canvas.Top" Value="{Binding Y}"/>
                </Style>
            </ItemsControl.ItemContainerStyle>

