0
我想将样式中的ContextMenu的MenuItem的CommandTarget设置为样式目标,即样式适用的控件。如何在样式中的ContextMenu中绑定到样式目标?
<Style x:Key="AAA" TargetType="{x:Type BBB}">
<Setter Property="ContextMenu">
<Setter.Value>
<ContextMenu>
<MenuItem Command="{x:Static CCC}" CommandTarget="{Binding ???}"/>
</ContextMenu>
</Setter.Value>
</Setter>
</Style>
我试过RelativeSource TemplatedParent,Self,FindAncestor,它们都不起作用。有没有其他的方法来选择目标?
我试过但未成功。不过,我使用了一种解决方法,只是省略了命令目标,并在上下文菜单打开时设置了重点控制。谢谢! – Tinro 2010-08-16 04:08:24