简体   繁体   English

获取上下文菜单Windows Phone的父控件

[英]Get Parent control of context menu Windows phone

I have Context Menu when hold to grid 按住网格时有上下文菜单

<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>

How can I get <Grid Tag="1" Tap="Grid_Tap" Style="{StaticResource GridMedium}"></Grid> by code behide MenuItem_Tap event 如何通过隐藏MenuItem_Tap事件的代码获取<Grid Tag="1" Tap="Grid_Tap" Style="{StaticResource GridMedium}"></Grid>

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

Please find the link for attached project 请找到附加项目的链接

I created a sample application for you. 我为您创建了一个示例应用程序。 Please check the one I attached and if you still have any other issues update your issues as comments. 请检查我所附的问题,如果还有其他问题,请通过评论更新您的问题。

Also if you are satisfied with the answer provided. 另外,如果您对提供的答案感到满意。 Please mark it as answered. 请标记为已回答。

Rakesh R 拉克什R

<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..
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在Windows Phone 8.1中避免上下文菜单的父级动画 - Avoid animation of the parent of context menu in windows phone 8.1 Windows Phone应用程序-获取称为上下文菜单的项目的索引 - Windows Phone app - get index of item that called context menu 如何使用父控件的上下文菜单覆盖文本框上下文菜单? - How to override textbox context menu with parent control's context menu? 将标题绑定到上下文菜单-Windows Phone - Binding a header to context menu- windows phone 使用Webbrowser控件在Windows Phone 8中打开手风琴菜单 - Accordion menu in windows phone 8 by using webbrowser control 上下文菜单未出现在Windows Phone 8列表框中 - Context Menu doesn't appear on windows phone 8 listbox 如何在Windows Phone 8中隐藏特定列表项的上下文菜单? - How to hide context menu for particular list item in Windows Phone 8? 将Windows Phone上下文菜单的Silverlight工具箱添加到C#中的listboxitem - Adding a silverlight toolkit for windows phone context menu to a listboxitem in C# 以编程方式添加到Messenger上下文菜单Windows Phone 8.1 - Programatically adding to Messenger context menu Windows Phone 8.1 在列表框Windows Phone的空白区域中选择时,上下文菜单未出现 - Context menu not appearing when selecting on empty area of listbox windows phone
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM