2013-09-25 80 views
0

我遇到了問題,WebVie總是在最前面,我有LoadingGrid(帶有圖像的黑色背景)它haz Z.Index = 5。Windows 8 WebView

我第一件事顯示加載屏幕,當WebView完成加載後,我隱藏加載屏幕和淡入WebView。

但問題是WebView甚至與不透明度設置爲0 - 可見!在我的加載屏幕上方 - 是否有解決方法?因爲只有這樣,我發現做的WebView看不見設置爲崩潰 - 但後來我的效果沒有任何理由...

<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}"> 
    <VisualStateManager.VisualStateGroups> 
     <VisualStateGroup x:Name="ShowHideWebView"> 
      <VisualStateGroup.Transitions> 
       <VisualTransition GeneratedDuration="0:0:0.2"/> 
      </VisualStateGroup.Transitions> 
      <VisualState x:Name="HideWebView"/> 
      <VisualState x:Name="ShowWebView"> 
       <Storyboard> 
        <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="wv1" d:IsOptimized="True"/> 
       </Storyboard> 
      </VisualState> 
     </VisualStateGroup> 
    </VisualStateManager.VisualStateGroups> 
    <Grid.RowDefinitions> 
     <RowDefinition Height="*"/> 
     <RowDefinition Height="18*"/> 
    </Grid.RowDefinitions> 
    <!-- 
    <Button x:Name="bBack" BorderThickness="0" Grid.Row="0" HorizontalAlignment="Left" VerticalAlignment="Stretch" Click="bBackClick" > 
     <Button.Background> 
      <ImageBrush ImageSource="Assets/back_button.png" Stretch="UniformToFill"/> 
     </Button.Background> 
    </Button> --> 

    <WebView x:Name="wv1" HorizontalAlignment="Stretch" Visibility="Collapsed" Grid.Row="1" VerticalAlignment="Stretch" LoadCompleted="wv1_LoadCompleted" Opacity="0" /> 
    <Image HorizontalAlignment="Left" VerticalAlignment="Top" Grid.Row="0" Source="Assets/back_button.png" Tapped="backClick" /> 
    <Grid x:Name="LoadingScreen" Grid.Row="1" Visibility="Collapsed" Canvas.ZIndex="5"> 
     <Grid.Background> 
      <SolidColorBrush Color="Black" Opacity="0.5"/> 
     </Grid.Background> 
     <Image Height="100" Width="100" Opacity="0.5" Source="Assets/loading.gif" Stretch="Fill"> 
      <Image.RenderTransform> 
       <RotateTransform x:Name="SpinningRotateTransform" CenterX="50" CenterY="50" /> 
      </Image.RenderTransform> 
     </Image> 
    </Grid> 
</Grid> 

回答

0

你必須堅持Visibility財產,因爲當不透明度當時WebView爲0將是可視化樹的一部分,因此它將在每個元素的頂部。如果它被摺疊,它不再是視覺樹的一部分。我會建議嘗試WebViewBrush以顯示淡入淡出效果。當效果結束時顯示WebView