2013-07-17 65 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 –

相關問題