【问题标题】:Center a popup/UserControl居中弹出/用户控件
【发布时间】:2023-04-05 03:37:01
【问题描述】:

我想将 PopUp 准确地置于屏幕中心。 我使用了一个用户控件在弹出窗口中显示。 但是我计算水平偏移和垂直偏移的方式是错误的。

        Popup popUp = new Popup();
        ProgressScreen progressScreen = new ProgressScreen();
        popUp.Child = progressScreen;
        //popUp.HorizontalOffset = (this.ActualWidth/2) + (progressScreen.ActualWidth / 2);
        popUp.VerticalOffset = (this.ActualHeight / 2) + (progressScreen.ActualHeight / 2);
        popUp.HorizontalOffset = (this.ActualWidth - progressScreen.ActualWidth) / 2;
        popUp.Height = this.ActualHeight;
        popUp.Width = this.ActualWidth;
        popUp.IsOpen = true;

【问题讨论】:

    标签: windows xaml windows-phone


    【解决方案1】:

    我认为这应该可以正常工作

    popUp.Placement = System.Windows.Controls.Primitives.PlacementMode.Center;

    但是为了正常工作,弹出窗口应该放在一个占据整个屏幕的容器中

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-04
      • 1970-01-01
      • 2023-03-26
      相关资源
      最近更新 更多