如何防止ApplicationBar在WP7白色主题上闪烁?

bka*_*aid 8 c# flicker windows-phone-7 application-bar windows-phone-7.1

我有一个Windows Phone 7.1芒果应用程序,我大多成功地覆盖了内置的主题颜色.但是,如果用户选择了白色主题并且页面具有深色背景和暗应用程序栏,则应用程序栏将呈现并使用白色背景进行动画处理,从而导致恼人的闪烁.完成后,动画背景颜色会适当地设置为深色.

有没有办法禁用应用栏动画或设置其初始动画背景颜色?

请参阅此视频捕捉的闪烁问题.

XAML:

<phone:PhoneApplicationPage x:Class="AppBarFlickers.Page1"
                            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:d="http://schemas.microsoft.com/expression/blend/2008"
                            xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                            xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
                            mc:Ignorable="d"
                            d:DesignWidth="480"
                            d:DesignHeight="728"
                            SupportedOrientations="Portrait"
                            Orientation="Portrait">
    <Grid Background="Black">
        <Button Content="Toggle App Bar"
                Margin="100,185,100,0"
                VerticalAlignment="Top"
                Click="ButtonClick"
                Foreground="White"
                Background="Black"
                BorderBrush="White" />
    </Grid>
    <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar BackgroundColor="Black"
                              ForegroundColor="White">
            <shell:ApplicationBarIconButton IconUri="/icon.png"
                                            Text="Button 1" />
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>
</phone:PhoneApplicationPage>
Run Code Online (Sandbox Code Playgroud)

代码背后:

public partial class Page1
{
   public Page1()
   {
       InitializeComponent();
   }

   private void ButtonClick(object sender, RoutedEventArgs e)
   {
       ApplicationBar.IsVisible = !ApplicationBar.IsVisible;
   }
}
Run Code Online (Sandbox Code Playgroud)

Kev*_*sse 19

看起来ApplicationBar隐藏时未加载背景.它隐藏了条形,然后加载背景,因此闪烁.

找到解决方法:将应用程序栏的不透明度设置为0.99.它足够高,透明度不可见,它将强制应用程序加载背景.

<phone:PhoneApplicationPage.ApplicationBar>
    <shell:ApplicationBar BackgroundColor="Black" ForegroundColor="White" Opacity=".99" >
        <shell:ApplicationBarIconButton IconUri="/icon.png" Text="Button 1" />
    </shell:ApplicationBar>
</phone:PhoneApplicationPage.ApplicationBar>
Run Code Online (Sandbox Code Playgroud)