我有一个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;
}
}
最佳答案
看起来在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>