0

我正在尝试在我的 Metro 应用程序中使用 AppBar。问题是,我还有一些 WebView 正在 AppBar 上显示。这是我的代码:

<Page
x:Class="AppName.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:AppName"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">

<Grid Background="#00D4FF" Canvas.ZIndex="1">
    <WebView Source="http://bing.com/"
        VerticalAlignment="Center" Margin="306,518,360,25" 
             Canvas.ZIndex="1" Height="225" />
</Grid>
<Page.BottomAppBar>
    <AppBar x:Name="ABar" IsSticky="True" Padding="10,0,10,0" Canvas.ZIndex="200">
        <Grid>
            <StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
                <Button Style="{StaticResource EditAppBarButtonStyle}" x:Name="EditButton" Visibility="Collapsed" />
                <Button Style="{StaticResource AddAppBarButtonStyle}" />
                <Button Style="{StaticResource DeleteAppBarButtonStyle}" x:Name="DelButton" Visibility="Collapsed" />
            </StackPanel>
        </Grid>
    </AppBar>
</Page.BottomAppBar>

如果您运行它并调出 appbar,您会注意到 WebView 显示在 appbar 上方,即使 AppBar 的 Canvas.ZIndex 高于 WebView 和 Grid 的 ZIndex。我该如何防止这种情况发生?

4

1 回答 1

1

您需要使用 WebViewBrush 控件,该控件将在应用栏处于活动状态时显示 WebView 内容。在应用栏显示事件中,您隐藏 WebView 控件并显示 WebViewBrush,而在应用栏隐藏事件中执行相反的操作。实现这一点的棘手部分是正确获取动画时间。

下面链接的文章包含一个如何做到这一点的示例,虽然它与魅力栏有关,但原理相同。

http://blogs.msdn.com/b/priozersk/archive/2012/08/13/how-to-display-charms-on-a-top-of-the-webview.aspx

于 2012-10-07T20:50:56.757 回答