Firstly, something strange is that you are trying to set the Command and the Click event. You must install one or the other. Perhaps the fact that the action is disabled is that you set the command with the value CanExecute = false;
Instead of writing a DataTemplate, you can try setting the ItemContainerStyle for the ListBoxItem as follows:
<ListBox> <ListBox.ItemContainerStyle> <Style TargetType="ListBoxItem"> <Setter Property="ContextMenu"> <Setter.Value> <ContextMenu> <MenuItem Header="Delete" Click="DeleteEvent"/> </ContextMenu> </Setter.Value> </Setter> <Setter Property="Content" Value="{Binding Path=EventName}"/> </Style> </ListBox.ItemContainerStyle> </ListBox>
Here, I directly set the ContextMenu of the ListBoxItem instance so that it displays the menu in the right control.
source share