单击UWPToolkit AdaptiveGridView时无响应

时间:2017-10-22 17:44:54

标签: c# xaml uwp windows-community-toolkit

我试图使用AdaptiveGridView作为主菜单导航到其他页面,所以我想我会在其上测试一个点击事件,根据我对下面可以找到的样本仓库的理解,你可以使用点击事件启用click可以执行某些操作,具体取决于单击的项目:

https://github.com/Microsoft/UWPCommunityToolkit/tree/master/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/AdaptiveGridView

看起来很直接但是当我尝试在我自己的代码中触发click事件时,当弹出窗口出现时没有任何反应。

C#Click Event:

private async void AGVC_ItemClick(object sender, Windows.UI.Xaml.Controls.ItemClickEventArgs e)
        {
                await new MessageDialog($"You clicked {(e.ClickedItem as AdaptItem).Title}", "Item Clicked").ShowAsync();
        }

我的XAML页面中的网格:

<Controls:AdaptiveGridView Name="AGVC"
                                   OneRowModeEnabled="False"
                                   ItemHeight="200"
                                   DesiredWidth="200"
                                   SelectionMode="Single"
                                   IsItemClickEnabled="True"
                                   VerticalAlignment="Top"
                                   ItemTemplate="{StaticResource MenuTemplate}" HorizontalAlignment="Left"/>
                <StackPanel VerticalAlignment="Bottom" Margin="0,24,0,0" Grid.Row="1" Background="{ThemeResource SystemControlBackgroundAccentBrush}">

1 个答案:

答案 0 :(得分:0)

AdaptiveGridView

中缺少项目
<Controls:AdaptiveGridView Name="AGVC"
                                   OneRowModeEnabled="False"
                                   ItemHeight="200"
                                   DesiredWidth="200"
                                   SelectionMode="Single"
                                   IsItemClickEnabled="True"
                                   VerticalAlignment="Top"
                                   ItemClick="AGVC_ItemClick"
                                   ItemTemplate="{StaticResource MenuTemplate}" HorizontalAlignment="Left" />