2013-07-17 117 views
1

问题是当我的设备的主题设置为黑暗时,在显示和隐藏ApplicationBar动画时出现黑色背景。我要么是白色的,要么没有背景。ApplicaionBar在隐藏或显示时显示黑色背景

Here is a video that shows it

我的XAML文件

<phone:PhoneApplicationPage 
    x:Class="AppBarTest.MainPage" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone" 
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    mc:Ignorable="d" 
    FontFamily="{StaticResource PhoneFontFamilyNormal}" 
    FontSize="{StaticResource PhoneFontSizeNormal}" 
    Foreground="{StaticResource PhoneForegroundBrush}" 
    SupportedOrientations="Portrait" Orientation="Portrait" 
    shell:SystemTray.IsVisible="True"> 

    <phone:PhoneApplicationPage.ApplicationBar> 
     <shell:ApplicationBar Mode="Default" Opacity="1.0" IsMenuEnabled="False" IsVisible="True" BackgroundColor="#AAAAAA" ForegroundColor="Black"> 
      <shell:ApplicationBarIconButton IconUri="/Assets/add.png" Text="add"/> 
      <shell:ApplicationBarIconButton IconUri="/Assets/delete.png" Text="delete"/> 
      <shell:ApplicationBarIconButton IconUri="/Assets/feature.camera.png" Text="camera"/> 
     </shell:ApplicationBar> 
    </phone:PhoneApplicationPage.ApplicationBar> 
    <Grid Background="White"> 
     <Button Content="Hide/Show" HorizontalAlignment="Center" VerticalAlignment="Top" Foreground="Black" Background="Green" Click="Button_Click" Margin="112,66,122,0" Height="150" Width="246"/> 
    </Grid> 
</phone:PhoneApplicationPage> 


我的CS文件

public partial class MainPage : PhoneApplicationPage 
{ 
    // Constructor 
    public MainPage() 
    { 
     InitializeComponent(); 
    } 

    private void Button_Click(object sender, RoutedEventArgs e) 
    { 
     ApplicationBar.IsVisible = !ApplicationBar.IsVisible; 
    } 
} 

回答

2

这种现象是由于应用程序任务栏没有实际作为网页的一部分,但实际上是一部分的外壳。

当包含ApplicationBar时,它会调整应用程序可用空间的大小。因此,您的页面不占用ApplicationBar后面的空间,因此默认背景颜色会显示。

最简单的方法来改变这是没有一个不透明的ApplicationBar。通过向ApplicationBar添加一定级别的透明度(即使是1%),它将显示在页面顶部,而不是在其下面。
这将解决隐藏ApplicationBar时的问题,但您现在需要处理显示在其后面的内容。

+0

劳尔它工作。好的解释只是设置了“不透明度=”0.99“'。如果可以的话,我愿意给你100张选票:) –

+0

@InderKumarRathore你总是可以找到我的一些其他答案,并使他们满意;)http://stackoverflow.com/users/1755/matt-lacey?tab=answers –

+0

他他他...:DI已经做到了:D –

相关问题