0

If I tap on a pushpin, Contextmenu is opening and displaying the details.. Now I want To Tap/Click on the Contextmenu to do some events.. How to achieve this??? Thanks

<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;
        }
    }
4

1 回答 1

0

要处理 ContextMenuItem 上的点击/单击,您必须添加适当的事件。

例如

<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>
于 2013-01-30T13:14:40.383 回答