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

Posted

技术标签:

【中文标题】如何防止 WP7 白色主题上的 ApplicationBar 闪烁?【英文标题】:How can you prevent the ApplicationBar flickering on the WP7 white theme? 【发布时间】:2012-02-03 15:13:43 【问题描述】:

我有一个 Windows Phone 7.1 Mango 应用程序,其中大部分成功地覆盖了内置主题颜色。但是,如果用户选择了白色主题并且页面具有深色背景和深色应用程序栏,则应用程序栏会以白色背景呈现和动画,这会导致烦人的闪烁。完成动画后,背景颜色会适当地设置为深色。

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

看到这个video capture of the flickering issue.

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>

后面的代码:

public partial class Page1

   public Page1()
   
       InitializeComponent();
   

   private void ButtonClick(object sender, RoutedEventArgs e)
   
       ApplicationBar.IsVisible = !ApplicationBar.IsVisible;
   

【问题讨论】:

【参考方案1】:

在 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>

【讨论】:

当,+25 代表给你。这也解释了为什么它不在没有纯色背景的屏幕上执行此操作,因为那里有一个透明的应用栏。谢谢! 你们是怎么知道这些事情的:-)

以上是关于如何防止 WP7 白色主题上的 ApplicationBar 闪烁?的主要内容,如果未能解决你的问题,请参考以下文章

WP7:了解暗/亮图标以及如何根据它们动态更改(通过mvvmlight)?

如何防止 WP8 Panorama Control 暂时滑动?

如何防止自定义 UITableViewCells 在取消选择时闪烁白色?

WP7 设备上的设备主音量

如何在 Windows Phone 8 上获得 WP7 风格的 ANID?

与WP7.5上的匿名对象绑定