如何设置绑定项目的ContextMenu?
我试图实现以下目标:
<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
I am trying to achieve the following:
<Style TargetType="ListBoxItem">
<Setter Property="ContextMenu">
<Setter.Value>
<ContextMenu>
<MenuItem Name="mnuEdit" Header="_Edit" Click="MenuItem_Click" />
</ContextMenu>
</Setter.Value>
</Setter>
<Style>
But it throws the following exception:
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
试试这个:
Try this instead: