Reputation: 887
I got the following code in my xaml file:
...
<ListView ...>
<ListView.ItemContainerStyle>
<Setter Property="ContextMenu">
<Setter.Value>
<ContextMenu>
...
...
If I run the application in debug mode I get a System.Windows.Markup.XamlParseException at the ContextMenu with an additional information as follows:
German original:
Additional information: Einem Objekt vom Typ "System.Object" kann kein Inhalt vom Typ "System.Windows.Controls.ContextMenu" hinzugefügt werden.
My english translation (I dont know the original english message):
Additional information: You cannot add content of the type "System.Windows.Controls.ContextMenu" to an object of the type "System.Object".
I ported the application from .NET4.0 down to .NET3.5 for compatibility reasons. In .NET4.0 it worked without problems.
What's the problem and how to solve this?
Further information:
Upvotes: 0
Views: 32
Reputation: 346
try this
<ContextMenu x:Key="contextMenu">
<MenuItem Name="mnuEdit" Header="_Edit" Click="MenuItem_Click" />
</ContextMenu>
<Style TargetType="ListBoxItem">
<Setter Property="ContextMenu" Value="{DynamicResource contextMenu}" />
</Style>
Upvotes: 1