I am trying to bind the header of the context menu to a property of the selected item of the respective ListView
. The objects of the ItemsSource
have an IsDuplicate
property. Any idea what is wrong?
<ListView x:Name="AthletesListView" ItemsSource="{Binding FoundAthletes}">
<ListView.ContextMenu>
<ContextMenu>
<MenuItem Name="AddorEditAthleteMenuItem"
Header="{Binding SelectedItem.IsDuplicate,
ElementName=AthletesListView,
Converter={StaticResource FoundAthletesAddEditMenuItemConverter}}"
Click="AddAthleteMenuItem_Click"/>
</ContextMenu>
</ListView.ContextMenu>
Below the error message:
System.Windows.Data Error: 4 : Cannot find source for binding with reference 'ElementName=AthletesListView'. BindingExpression:Path=SelectedItem; DataItem=null; target element is 'MenuItem' (Name='AddorEditAthleteMenuItem'); target property is 'Header' (type 'Object')