2

按住网格时我有上下文菜单

<Grid Tag="1" Tap="Grid_Tap" Style="{StaticResource GridMedium}">
    <Grid.Background>
        <ImageBrush Stretch="Fill" ImageSource="/Assets/Images/Page/bg_haivl.png"/>
    </Grid.Background>
    <toolkit:ContextMenuService.ContextMenu>
        <toolkit:ContextMenu>
            <toolkit:MenuItem Header="pin to start" Tap="MenuItem_Tap"/>
        </toolkit:ContextMenu>
    </toolkit:ContextMenuService.ContextMenu>
    <Image Source="/Assets/Images/Page/icon_haivl.png" HorizontalAlignment="Center" VerticalAlignment="Top" Width="94" Margin="0,14,0,0" />
    <Image Source="/Assets/Images/Page/logo_haivl.png" HorizontalAlignment="Left" VerticalAlignment="Bottom" Width="32" Margin="8,0,0,10" />
</Grid>

如何<Grid Tag="1" Tap="Grid_Tap" Style="{StaticResource GridMedium}"></Grid>通过 MenuItem_Tap 事件背后的代码获取

private void MenuItem_Tap(object sender, System.Windows.Input.GestureEventArgs e)
{
    MenuItem menuItem = (MenuItem)sender;
    //...Select Grid here
}
4

2 回答 2

1

请找到附加项目的链接

我为您创建了一个示例应用程序。请检查我附加的那个,如果您还有任何其他问题,请将您的问题更新为评论。

另外,如果您对提供的答案感到满意。请将其标记为已回答。

拉克什

于 2013-09-12T07:10:43.300 回答
0
<Grid x:Name ="MyGrid" Tag="1" Tap="Grid_Tap" Style="{StaticResource GridMedium}">
<Grid.Background>
    <ImageBrush Stretch="Fill" ImageSource="/Assets/Images/Page/bg_haivl.png"/>
</Grid.Background>
<toolkit:ContextMenuService.ContextMenu>
    <toolkit:ContextMenu>
        <toolkit:MenuItem Header="pin to start" Tap="MenuItem_Tap"/>
    </toolkit:ContextMenu>
</toolkit:ContextMenuService.ContextMenu>
<Image Source="/Assets/Images/Page/icon_haivl.png" HorizontalAlignment="Center" VerticalAlignment="Top" Width="94" Margin="0,14,0,0" />
<Image Source="/Assets/Images/Page/logo_haivl.png" HorizontalAlignment="Left" VerticalAlignment="Bottom" Width="32" Margin="8,0,0,10" />

private void MenuItem_Tap(object sender, System.Windows.Input.GestureEventArgs e)
{
    MenuItem menuItem = (MenuItem)sender;

    //MyGrid.  // Access you grid here..
}
于 2013-09-11T07:23:24.537 回答