Flyout 或 Popup 以显示附加信息

Flyout or Popup to display addition info

我想在我的应用程序顶部显示带有附加信息的弹出窗口,我的信息是 Listview 约 500 个项目我都试过了:

那么我应该走哪条路,尝试编辑弹出窗口的模板或通过设置垂直和水平偏移使我的弹出窗口居中? 或者有更好的方法来显示像 window 这样的弹出窗口,其中包含诸如项目列表或其他

之类的信息

默认情况下,Flyout里面有一个ScrollViewer。如果需要,您可以在 FlyoutPresenter styles and templates. You can edit it and use new template by setting Flyout.FlyoutPresenterStyle 属性 找到它的模板。

如果要使用 PopupHorizontalAlignmentVerticalAlignment 属性,您需要将 Popup 添加为元素中的子元素视觉树。例如:

Popup myPopup = new Popup();
//MainGrid is the top Grid in the Page
MainGrid.Children.Add(myPopup);
myPopup.HorizontalAlignment = HorizontalAlignment.Center;
myPopup.VerticalAlignment = VerticalAlignment.Center;
myPopup.Child = myListView;
myPopup.IsOpen = true;

但请注意,这实际上不会使 Popup 居中。它使 Popup 的左上角居中。在 Popup classRemarks 部分,它说:

You position the Popup by setting the HorizontalOffset and VerticalOffset properties. The Popup is offset relative to its immediate parent container.

我认为在使用 HorizontalAlignment.CenterVerticalAlignment.Center 时,它将 HorizontalOffsetVerticalOffset 设置为其父级宽度和高度的一半。

并且在备注部分,它还说:

Do not use a Popup if a Flyout, MenuFlyout, ToolTip or MessageDialog is more appropriate.

所以我认为在你的情况下使用 Flyout 是更好的方法。