显示等待屏幕Windows Phone 8

时间:2013-01-03 11:31:20

标签: c# windows-phone-8

我的应用程序中的某些操作需要一些时间,我想显示等待屏幕,以便用户在操作完成之前可能不会执行任何操作。

请让我知道我该怎么做。

1 个答案:

答案 0 :(得分:1)

您可以编辑Frame模板并以这种方式插入特殊控件:

<Style x:Key="mainFrameStyle" TargetType="phone:PhoneApplicationFrame">
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="phone:PhoneApplicationFrame">
            <Border x:Name="ClientArea" BorderBrush="{TemplateBinding BorderBrush}"
                    BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}"
                    HorizontalAlignment="{TemplateBinding HorizontalAlignment}" VerticalAlignment="{TemplateBinding VerticalAlignment}">
                    <Grid x:Name="mainFrameGrid">
                        <ContentControl ContentTemplate="{TemplateBinding ContentTemplate}"
                                Content="{TemplateBinding Content}" HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
                                HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                                VerticalAlignment="{TemplateBinding VerticalAlignment}"
                                VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" />

                        <Grid Background="Black" Visibility="{Binding IsBusy, Converter={StaticResource TrueToVisibleConverter}, Source={StaticResource FrameViewModel}}">
                            <TextBlock Text="Loading.." VerticalAlignment="Center" HorizontalAlignment="Center"/>
                        </Grid>
                    </Grid>
                </Border>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

并使用以下代码在InitializePhoneApplication()中的App.xaml.cs中应用此模板:

    RootFrame = new TransitionFrame();
    RootFrame.Style = Resources["mainFrameStyle"] as Style;

所以你需要的是将一些viewmodel注册为staticresource并在需要时更改它的IsBusy属性。