Windows应用商店:页面元素加载是跳跃,令人厌烦

时间:2013-07-02 14:56:54

标签: windows-store

我有一个带有图片的页面,其来源是本地的.png资产。它以最烦人的方式加载到视图中。

它加载整个网格,如RowSpan =“2”,然后在一两秒后弹出到位。太糟糕了。

基于新的空白商店应用程序从repro应用程序演示。

<common:LayoutAwarePage
    x:Name="pageRoot"
    x:Class="DeleteMeApp1.BasicPage1"
    DataContext="{Binding DefaultViewModel, RelativeSource={RelativeSource Self}}"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:DeleteMeApp1"
    xmlns:common="using:DeleteMeApp1.Common"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

    <Page.Resources>

        <!-- TODO: Delete this line if the key AppName is declared in App.xaml -->
        <x:String x:Key="AppName">My Application</x:String>
    </Page.Resources>

    <!--
        This grid acts as a root panel for the page that defines two rows:
        * Row 0 contains the back button and page title
        * Row 1 contains the rest of the page layout
    -->
    <Grid Style="{StaticResource LayoutRootStyle}" Background="Brown">
        <Grid.RowDefinitions>
            <RowDefinition Height="140"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <VisualStateManager.VisualStateGroups>

            <!-- Visual states reflect the application's view state -->
            <VisualStateGroup x:Name="ApplicationViewStates">
                <VisualState x:Name="FullScreenLandscape"/>
                <VisualState x:Name="Filled"/>

                <!-- The entire page respects the narrower 100-pixel margin convention for portrait -->
                <VisualState x:Name="FullScreenPortrait">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="backButton" Storyboard.TargetProperty="Style">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PortraitBackButtonStyle}"/>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>

                <!-- The back button and title have different styles when snapped -->
                <VisualState x:Name="Snapped">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="backButton" Storyboard.TargetProperty="Style">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SnappedBackButtonStyle}"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="pageTitle" Storyboard.TargetProperty="Style">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SnappedPageHeaderTextStyle}"/>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>

        <Image Grid.Row="0" Stretch="UniformToFill" Source="Assets/BackgroundTexturedBlackboard.png" />

        <!-- Back button and page title -->
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <Button x:Name="backButton" Click="GoBack" IsEnabled="{Binding Frame.CanGoBack, ElementName=pageRoot}" Style="{StaticResource BackButtonStyle}"/>
            <TextBlock x:Name="pageTitle" Grid.Column="1" Text="{StaticResource AppName}" Style="{StaticResource PageHeaderTextStyle}"/>
        </Grid>

        <StackPanel Grid.Row="1">

        </StackPanel>

    </Grid>
</common:LayoutAwarePage>

1 个答案:

答案 0 :(得分:0)

问题在于布局。虽然技术上合法,但这种安排效果不佳。

我通过在现有的根目录周围添加另一个网格并使新的网格成为新的根来解决了这个问题。

在新的根目录中,我添加了Image和我需要覆盖艺术作品的其他元素,这种元素的排序效果更好,但是,通过过渡效果,我仍需要调整它。

<强>更新

实际上,这不是故事的结尾。删除图像并仅留下具有不透明度0.5的矩形,矩形的不透明度在页面加载后设置为秒。太可怕了。

我制作了一个repro应用,录制了问题并提交了连接错误。

https://connect.microsoft.com/VisualStudio/feedback/details/792303/windows-store-xaml-atrocious-obvious-delayed-application-of-opacity#details