You could try using command bindings (you'll need prism):
...
<ContextMenu DataContext="{Binding PlacementTarget.DataContext, RelativeSource={RelativeSource Self}}">
<MenuItem Command="{Binding StartCommand}"/>
...
</ContextMenu>
...
...
using Microsoft.Practices.Composite.Presentation.Commands;
public class currentJob
{
public ICommand StartCommand {get; private set;}
public currentJob ()
{
StartCommand = new DelegateCommand(ExecuteStart, CanExecuteStart);
}
private bool CanExecuteStart()
{
//Determine whether start can be executed
return true;
}
private void ExecuteStart()
{
//start here
}
}
Here, ExecuteStart
replaces startJob
and CanExecuteStart
replaces enablePermitted
in the original example.
Edit It probably helps to explain why your original code does not work. Changes to bound properties are only picked up if a "PropertyChange" event is fired by the property's object. Implementing INotifyPropertyChanged would probably also fix your problem.
Edit An even more trivial problem with your original code is that it is binding to the wrong object - I presume no property startPermitted exists on FeedContextMenu (which anyway doesn't seem to be defined).
Edit There are still a few issues above: 1) the bindings are case-sensitive, so the binding should be {Binding StartCommand} etc. 2) You need to set the context menu on the individual items in the list. The following would work:
<ListView Margin="10,10,10,55" Name="listviewCurrentJobs" ItemsSource="{Binding JobCollection}">
<ListView.ItemTemplate>
<DataTemplate>
<Border BorderBrush="Black" BorderThickness="2">
<StackPanel Orientation="Horizontal" MinHeight="20" Background="White">
<StackPanel.ContextMenu>
<ContextMenu DataContext="{Binding PlacementTarget.DataContext, RelativeSource={RelativeSource Self}}">
<MenuItem Header="Starten" Command="{Binding Path=StartCommand}"/>
<MenuItem Header="Stoppen" Command="{Binding Path=StopCommand}"/>
<MenuItem Header="Aktivieren" Command="{Binding Path=EnableCommand}"/>
<MenuItem Header="Deaktivieren" Command="{Binding Path=DisableCommand}"/>
<MenuItem Header="Löschen" Command="{Binding Path=DeleteCommand}"/>
</ContextMenu>
</StackPanel.ContextMenu>
<Image Source="{Binding State}" Width="16"/>
</StackPanel>
</Border>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>