【发布时间】:2009-09-09 04:18:21
【问题描述】:
我正在努力实现以下目标:
<Style TargetType="ListBoxItem">
<Setter Property="ContextMenu">
<Setter.Value>
<ContextMenu>
<MenuItem Name="mnuEdit" Header="_Edit" Click="MenuItem_Click" />
</ContextMenu>
</Setter.Value>
</Setter>
<Style>
但它会抛出以下异常:
Cannot add content of type 'System.Windows.Controls.ContextMenu'
to an object of type 'System.Object'.
Error at object 'System.Windows.Controls.ContextMenu'
in markup file blah blah blah
【问题讨论】:
标签: wpf styles contextmenu listboxitem setter