如何显示的Windows Phone 8.1全屏幕模态ContentDialog [英] How to show a full screen Modal ContentDialog in Windows Phone 8.1

查看:346
本文介绍了如何显示的Windows Phone 8.1全屏幕模态ContentDialog的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当用户试图登录到我的应用程序,我显示包含几个的TextBlocks和进度一ContentDialog。

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

我选择ContentDialog,因为它是形式上的,阻止用户,直到应用程序收集所需的信息,并准备导航到下一个页面。

I choose ContentDialog because it is modal and blocks the user until the application collects required information and is ready to navigate to next page.

下的链接显示内容对话框类,可用于Windows Phone的8.1(通用应用程序)。

The following link shows the Content Dialog Class that is available for Windows Phone 8.1(Universal Apps).

下面的代码显示了我写来显示ContentDialog代码隐藏(我暂时把这个的OnNavigatedTo进行测试,稍后将其移动到适当的通知功能)

The following code displays the code-behind that I have written to display the ContentDialog (I have temporarily put this in OnNavigatedTo for testing, will later move it to appropriate notification function)

//Progress Bar
ProgressBar bar = new ProgressBar();
bar.IsIndeterminate = true;

//Downloading Data text
TextBlock txt = new TextBlock();
txt.Text = "Downloading data...";
txt.FontSize = 17;
txt.Foreground = new SolidColorBrush(Colors.White);
txt.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Center;

//This could take a few seconds
TextBlock txt2 = new TextBlock();
txt2.Text = "This could take a few seconds.";
txt2.FontSize = 17;
txt2.Foreground = new SolidColorBrush(Colors.White);
txt2.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Center;

//Please do not close the application.
TextBlock txt3 = new TextBlock();
txt3.Text = "Please do not close the application.";
txt3.FontSize = 17;
txt3.Foreground = new SolidColorBrush(Colors.White);
txt3.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Center;

StackPanel stk = new StackPanel();
stk.Children.Add(bar);
stk.Children.Add(txt);
stk.Children.Add(txt2);
stk.Children.Add(txt3);


ContentDialog dlg = new ContentDialog();
dlg.Content = stk;
SolidColorBrush color = new SolidColorBrush(Colors.Black);
color.Opacity = 0.7;
dlg.Background = color;
dlg.Margin = new Thickness(0, 250, 0, 0);
dlg.ShowAsync();

这将显示为

上面可以看到它仅覆盖背景的一部分。

This is displayed as Above you can see it is only covering part of the background

我想它显示为

I want it to be displayed as

通过全屏模式。

我试图改变高度和其他属性,但无法得到它的工作。

I have tried changing the height and other properties but was unable to get it to work.

我会很高兴,如果有人能在正确的方向指向我。

I would be glad if someone can point me in the right direction.

推荐答案

我发现其背后消除代码的溶液。不知道这更多的是一种工作的周围。但它可以让我轻松地使用绑定来决定何时显示此模式对话框时将其隐藏。

I found a solution which eliminates the code behind. Not sure if this is more of a work around. But it allows me to easily use Binding to decide when to display this modal dialog and when to hide it.

这是我的XAML

<Grid>
<Grid Visibility="{Binding IsDownloadingData}" Canvas.ZIndex="1" Background="{StaticResource PartiallyTransparentBlackColor}" HorizontalAlignment="Stretch">
    <Grid.RowDefinitions>
        <RowDefinition Height="*" />
        <RowDefinition Height="Auto" />
        <RowDefinition Height="Auto" />
        <RowDefinition Height="Auto" />
        <RowDefinition Height="Auto" />
        <RowDefinition Height="*" />
    </Grid.RowDefinitions>
    <ProgressBar Grid.Row="1" IsIndeterminate="True"/>
    <TextBlock Grid.Row="2" Text="Downloading Data..." FontSize="17" Foreground="White" HorizontalAlignment="Center"/>
    <TextBlock Grid.Row="3" Text="This could take a few seconds." FontSize="17" Foreground="White" HorizontalAlignment="Center"/>
    <TextBlock Grid.Row="4" Text="Please do not close the application." FontSize="17" Foreground="White" HorizontalAlignment="Center"/>
</Grid>
<ScrollViewer Canvas.ZIndex="0" VerticalAlignment="Stretch" Margin="0,10,0,10">
    <!-- The XAML that should be hidden goes here (In my case LOGIN PAGE XAML) -->
</ScrollViewer>



我的知名度玩的有Canvas.ZIndex =1,使用绑定,并决定何时显示模式窗口的网格。

I play around with the visibility of the Grid that has Canvas.ZIndex="1" using Binding and decide when to display the modal window.

这篇关于如何显示的Windows Phone 8.1全屏幕模态ContentDialog的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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