[英]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.