我遇到了问题,WebVie 总是在顶部,我有 LoadingGrid(上面有图像的黑色背景)它 haz Z.Index = 5。
首先我显示加载屏幕,当 WebView 完成加载时,我隐藏加载屏幕并淡入 WebView。
但问题是,即使不透明度设置为 0,WebView 也是可见的!在我的加载屏幕上 - 有解决方法吗?因为我发现使 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>