如何在Windows应用商店应用中的ListView/GridView中单击项目显示弹出/跳出

And*_*ord 6 c# listview flyout windows-store-apps

我正在开发Windows应用商店应用,并希望显示有关在ListView或GridView中单击的项目的一些其他信息.此信息应显示在单击项旁边的弹出窗口或弹出窗口中(在C#中定义,而不是在XAML中定义).

问题是,ItemClick事件处理程序不提供有关单击的可视项目的信息,而只提供有关数据项的信息.因此,我没有关于在屏幕上显示弹出窗口或弹出窗口的位置的信息.

cre*_*7or 17

使用附加的弹出窗口:

<DataTemplate x:Key="ListItemTemplate">
    <Grid RightTapped="ListRightTapped" Tapped="ListTapped" Background="Transparent">
        <Grid>
            ...
        </Grid>
        <FlyoutBase.AttachedFlyout>
            <Flyout Closed="listFlyout_Closed">
                <StackPanel>
                    ...
                </StackPanel>
            </Flyout>
        </FlyoutBase.AttachedFlyout>
    </Grid>
</DataTemplate>
Run Code Online (Sandbox Code Playgroud)

和代码:

private void ListRightTapped( object sender, RightTappedRoutedEventArgs e )
{
    FlyoutBase.ShowAttachedFlyout( sender as FrameworkElement );
}
Run Code Online (Sandbox Code Playgroud)

  • 此示例是MS应在其文档页面上提供的内容。谢谢。 (2认同)