Flyout 或 Popup 以显示附加信息 [英] Flyout or Popup to display addition info

查看:36
本文介绍了Flyout 或 Popup 以显示附加信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I want display popup on top my app with additional information, my info is Listview with ~500 items I've tried both:

  • flyout 的问题 -> 里面可能有 scrollViewer,所以我的列表视图不能正确虚拟化其他一切都可以.有我的代码:

  • problem with flyout -> it has probably scrollViewer inside so my listview doesn't Virtualize correctly everything else is ok. There is my code:

Flyout myFlyout = new Flyout();
myFlyout.Placement = FlyoutPlacementMode.Full;
myFlyout.Content = myListView;
myFlyout.ShowAt(this);   

  • popup 的问题 -> 它没有居中,verticalAlignment 不起作用,水平也没有

  • problem with popup -> it isn't centered, verticalAlignment doesn't work, horizontal neither

    Popup myPopup = new Popup();
    myPopup.Child = myListView;
    myPopup.IsOpen = true;
    

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

    So which way should I go, try to edit Template of flyout or center my popup by setting vertical and horizontal offset? Or there's better way to display popup like window with info like list of items or such other

    推荐答案

    默认情况下,Flyout 里面有一个 ScrollViewer.您可以在 FlyoutPresenter 样式和模板.您可以通过设置 Flyout.FlyoutPresenterStyle 属性(如果需要).

    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.

    如果你想使用PopupHorizo​​ntalAlignmentVerticalAlignment属性,你需要添加Popup作为可视化树中元素的子级.例如:

    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;
    

    但请注意,这实际上并没有使 Popup 居中.它使 Popup 的左上角居中.在弹出类,它说:

    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:

    您可以通过设置 Horizo​​ntalOffsetVerticalOffset 属性.Popup 相对于其直接父容器偏移.

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

    我认为在使用 Horizo​​ntalAlignment.CenterVerticalAlignment.Center 时,它将 Horizo​​ntalOffsetVerticalOffset 设置为其父级宽度和高度的一半.

    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.

    备注部分,它还说:

    如果 Flyout, MenuFlyout工具提示MessageDialog 更合适.

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

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

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

    这篇关于Flyout 或 Popup 以显示附加信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆