C# 带有ControlTemplate的ContextMenu中的Caliburn微动

C# 带有ControlTemplate的ContextMenu中的Caliburn微动,c#,wpf,mvvm,binding,caliburn.micro,C#,Wpf,Mvvm,Binding,Caliburn.micro,我有一个自定义组件,在ControlTemplate中有一个ContextMenu。我读过几篇文章,其中有人在上下文菜单中操作时遇到问题。我已经尝试了张贴在那里的解决办法,但我无法让它发挥作用。我一直没有找到打开方法的目标。但是,这些解决方案都没有使用ControlTemplate。我曾尝试将模型绑定到contextmenu、menuitems,以使用TargetWithoutContext属性,但似乎都不起作用 <components2:ImageBlock Background="T

我有一个自定义组件,在ControlTemplate中有一个ContextMenu。我读过几篇文章,其中有人在上下文菜单中操作时遇到问题。我已经尝试了张贴在那里的解决办法,但我无法让它发挥作用。我一直没有找到打开方法的目标。但是,这些解决方案都没有使用ControlTemplate。我曾尝试将模型绑定到contextmenu、menuitems,以使用TargetWithoutContext属性,但似乎都不起作用

 <components2:ImageBlock Background="Transparent" x:Name="ShareButton" Margin="0,0,7,0" >
     <components2:ImageBlock.Style>
          <Style TargetType="{x:Type components2:ImageBlock }">
               <Setter Property="ToolTipService.IsEnabled" Value="False"/>
               <Setter Property="Cursor" Value="Hand"/>
               <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
               <Setter Property="Template">
                    <Setter.Value>
                         <ControlTemplate TargetType="{x:Type components2:ImageBlock }">
                                <Grid x:Name="ContentGrid" Background="{TemplateBinding Background}" MinHeight="30" ToolTip="{TemplateBinding ToolTip}">
                                      <Grid.ContextMenu>
                                            <ContextMenu>
                                                 <MenuItem Header="Facebook" cal:Message.Attach="Open(0)"/>
                                                 <MenuItem Header="Twitter"  cal:Message.Attach="Open(1)]" />
                                                 <MenuItem Header="Tumblr" cal:Message.Attach="Open(2)]" />
                                             </ContextMenu>
                                       </Grid.ContextMenu>
                                </Grid>
                         </ControlTemplate>
                     </Setter.Value>
                </Setter>
           </Style>
      </components2:ImageBlock.Style>
  </components2:ImageBlock>
如何在视图后面的viewmodel上打开它?通过添加到ImageBlock的DependencyObject,我必须将ContextMenu的PlacementTarget设置为ImageBlock。奇怪的是,通过{Binding…}将ContextMenu的PlacementTarget直接设置到ImageBlock并没有起作用