0
我在ControlTemplate中有一個具有ContextMenu的自定義組件。我已經閱讀了幾篇文章,讓人們無法讓他們的行爲在ContextMenu中工作。我已經嘗試了在那裏發佈的解決方法,但我無法使其工作。我一直收到No target found for method Open.
但是,這些解決方案都不使用ControlTemplate。我試圖將模型綁定到contextmenu,menuitems,以使用TargetWithoutContext屬性,但似乎沒有任何工作。與ControlTemplate的ContextMenu中的Caliburn Micro Action
<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?
見下面...... – 2014-10-10 16:22:33