Windows8 - 数据加载层

时间:2013-04-29 09:52:29

标签: windows-8 windows-runtime winrt-xaml

我想屏蔽该应用并显示黑色或黑色透明图层,其中ProgressRing显示该应用正在加载数据。

由于

1 个答案:

答案 0 :(得分:0)

XAML

<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">

    <!-- Data will be loaded in GridView -->
    <GridView />

    <!-- Black layer with progress ring -->
    <Border x:Name="border" BorderBrush="Black" BorderThickness="1" Opacity="0.95" Background="Black" Visibility="Collapsed">
        <ProgressRing HorizontalAlignment="Center" VerticalAlignment="Center" IsActive="True" Width="100" Height="100" />
    </Border>

    <!-- Visual state will switch black layer and GridView -->
    <VisualStateManager.VisualStateGroups>
        <VisualStateGroup>
            <VisualState x:Name="Normal" />
            <VisualState x:Name="Dark">
                <Storyboard>
                    <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="border">
                        <DiscreteObjectKeyFrame KeyTime="0" Value="Visible" />
                    </ObjectAnimationUsingKeyFrames>
                </Storyboard>
            </VisualState>
        </VisualStateGroup>
    </VisualStateManager.VisualStateGroups>
</Grid>

C#

protected override void OnNavigatedTo(NavigationEventArgs e)
{
    VisualStateManager.GoToState(this, "Dark", true);

    //TODO: Load Data

    VisualStateManager.GoToState(this, "Normal", true);
}