I have:
<ListBox>
<ListBox.Resources>
<DataTemplate DataType="{x:Type ViewModels:StyleViewModel}">
<DockPanel>
<Button Content="{Binding Name}" Tag="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ListBox}}}">
<Button.ContextMenu>
<ContextMenu>
<MenuItem Header="Delete" Command="{Binding PlacementTarget.Tag.DataContext.RemoveMember1FavoriteStyleCommand}" CommandParameter="{Binding}" />
</ContextMenu>
</Button.ContextMenu>
</Button>
</DockPanel>
</DataTemplate>
</ListBox.Resources>
</ListBox>
What I'm trying to achieve is to bind the command in the menuitem of the context menu to an ICommand that is defined in a viewmodel that is the datacontext of the listbox, and the commandparameter should be the StyleViewModel, but what I tried didn't work. Can anyone point me in the right direction?