在GridView中,我试图在用户右键单击一个项目时显示上下文菜单。
我尝试过:
我尝试过:
<GridView.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Vertical" Width="120" Background="LightBlue">
<StackPanel.ContextFlyout>
<MenuFlyout>
<MenuFlyoutItem Text="Change color" Click="ChangeColorItem_Click" />
</MenuFlyout>
...
但是StackPanel.ContextFlyout
会抛出一个错误。我漏掉了什么?
更新
错误显示为:The attachable property 'ContextFlyout' was not found in type 'StackPanel'
ContextFlyout是UIElement的属性,而StackPanel从UIElement继承而来。