如果我点击图钉,则Contextmenu会打开并显示详细信息。 现在我想点击/点击Contextmenu来做一些事件.. 如何实现这个??? 感谢
<Style x:Key="MenuItemStyle" TargetType="toolkit:MenuItem">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="toolkit:MenuItem">
<StackPanel>
<TextBlock Text="{Binding Name}"
TextWrapping="Wrap"
Margin="24,0"
FontSize="26" Foreground="Black"/>
<TextBlock Text="{Binding Country}"
Margin="24,0"
FontSize="22" Foreground="Black"/>
<TextBlock Text="{Binding Status}"
Margin="24,0"
FontSize="22" Foreground="Black"/>
</StackPanel>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
private void Pushpin_ManipulationStarted(object sender, ManipulationStartedEventArgs e)
{
var _ppmodel = sender as Pushpin;
ContextMenu contextMenu =
ContextMenuService.GetContextMenu(_ppmodel);
contextMenu.DataContext = _viewModel.Pushpins.Where
(c => (c.Coordinates
== _ppmodel.Location)).FirstOrDefault();
if (contextMenu.Parent == null)
{
contextMenu.IsOpen = true;
}
}
答案 0 :(得分:0)
要处理对ContextMenuItem的点击/点击,您必须添加相应的事件。
e.g。
<Style x:Key="MenuItemStyle" TargetType="toolkit:MenuItem">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="toolkit:MenuItem">
<StackPanel Tap="OnMenuItemTapped">
...
</StackPanel>
</ControlTemplate>
</Setter.Value>
</Setter
</Style>