Flyout or Popup to display addition info

情到浓时终转凉″ 提交于 2019-12-04 12:09:56

By default, Flyout has a ScrollViewer inside. You can find its template at FlyoutPresenter styles and templates. You can edit it and use new template by setting Flyout.FlyoutPresenterStyle property if you need.

If you want to use Popup's HorizontalAlignment and VerticalAlignment property, you need add Popup as a child of an element in the visual tree. For example:

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;

But plesae note that this actually dose not make the Popup centered. It make the Popup's upper left corner centered. In the Remarks section of Popup class, it says:

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

I think while using HorizontalAlignment.Center and VerticalAlignment.Center, it set the HorizontalOffset and VerticalOffset to the half of its parent's width and height.

And in the Remarks section, it also says:

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

So I think in your case using Flyout is a better way.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!