1

我想在屏幕中间居中弹出用户控件,我该怎么做?

 Popup p = new Popup();
 p.Child = new loadingtest();

  p.isOpen = true;
4

1 回答 1

4
var p = new Popup();
var content = new TextBox { Text = "hello world!" };
p.Child = content;
p.VerticalOffset = (this.ActualHeight - content.ActualHeight) / 2;
p.HorizontalOffset = (this.ActualWidth - content.ActualWidth) / 2;
p.IsOpen = true;

PhoneApplicationPage在哪里this,popup 是LayoutRootGrid 的子项。

于 2013-10-03T21:23:35.690 回答