How to show a full screen Modal ContentDialog in Windows Phone 8.1

后端 未结 3 955
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-15 09:30

When a user is trying to login to my app, I am displaying a ContentDialog containing a few TextBlocks and a ProgressBar.

I choose ContentDialog because it is modal a

3条回答
  •  自闭症患者
    2020-12-15 10:03

    You can for example put a Grid as a content of your ContentDialog and set its Height/Width as Bounds of Current Window or your LayoutGrid:

    // your code
    stk.VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Center;
    Grid contentGrid = new Grid();
    contentGrid.Height = Window.Current.Bounds.Height;
    contentGrid.Width = Window.Current.Bounds.Width;
    // or from LayoutGrid
    //contentGrid.Height = LayoutRoot.ActualHeight;
    //contentGrid.Width = LayoutRoot.ActualWidth;
    contentGrid.Width -= 40; // it seems that ContentDialog has some defaul margin
    contentGrid.Children.Add(stk);
    
    ContentDialog dlg = new ContentDialog();
    dlg.Content = contentGrid;
    SolidColorBrush color = new SolidColorBrush(Colors.Black);
    color.Opacity = 0.7;
    dlg.Background = color;
    await dlg.ShowAsync();
    

    You can also think of using a PopUp.

提交回复
热议问题