我正在开发
Windows应用商店应用,并希望显示有关在ListView或GridView中单击的项目的一些其他信息.此信息应显示在单击项旁边的弹出窗口或弹出窗口中(在C#中定义,而不是在XAML中定义).
问题是,ItemClick事件处理程序不提供有关单击的可视项目的信息,而只提供有关数据项的信息.因此,我没有关于在屏幕上显示弹出窗口或弹出窗口的位置的信息.
解决方法
使用附加的弹出窗口:
<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>
和代码:
private void ListRightTapped( object sender,RightTappedRoutedEventArgs e )
{
FlyoutBase.ShowAttachedFlyout( sender as FrameworkElement );
}