Does anyone know why this would produce an XamlParseException "Cannot add content of type 'System.Windows.Controls.ContextMenu' to an object of type 'System.Object'":
<ItemsControl>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<Canvas ClipToBounds="True"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemContainerStyle>
<Style TargetType="ContentPresenter">
<Setter Property="ContextMenu">
<Setter.Value>
<ContextMenu>
<MenuItem Header="Remove" />
</ContextMenu>
</Setter.Value>
</Setter>
</Style>
</ItemsControl.ItemContainerStyle>
</ItemsControl>
And the following works just fine?
<ItemsControl>
<ItemsControl.Resources>
<ContextMenu x:Key="NodeContextMenu">
<MenuItem Header="Remove" />
</ContextMenu>
</ItemsControl.Resources>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<Canvas ClipToBounds="True"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemContainerStyle>
<Style TargetType="ContentPresenter">
<Setter Property="ContextMenu" Value="{StaticResource NodeContextMenu}" />
</Style>
</ItemsControl.ItemContainerStyle>
</ItemsControl>