如何防止 WP7 白色主题上的 ApplicationBar 闪烁?
我有一个 Windows Phone 7.1 Mango 应用程序,我基本上成功地覆盖了内置主题颜色。但是,如果用户选择了白色主题并且页面具有深色背景和深色应用程序栏,则应用程序栏将使用白色背景进行渲染和动画,这会导致烦人的闪烁。完成动画后,背景颜色将适当设置为深色。
有没有办法禁用应用程序栏动画或设置其初始动画背景颜色?
请参阅闪烁问题的视频捕获。
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;
}
}
I have a Windows Phone 7.1 Mango application where I have mostly successfully overridden the built in theme colors. However, if the user has the white theme selected and the page has a dark background and dark application bar, the application bar gets rendered and animated with a white background which causes an annoying flicker. After it gets done animating the background color gets sets to a dark color appropriately.
Is there a way to either disable the app bar animation or set its initial animation background color?
See this 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>
Code behind:
public partial class Page1
{
public Page1()
{
InitializeComponent();
}
private void ButtonClick(object sender, RoutedEventArgs e)
{
ApplicationBar.IsVisible = !ApplicationBar.IsVisible;
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来当 ApplicationBar 隐藏时背景未加载。它隐藏栏,然后加载背景,因此闪烁。
找到了解决方法:将应用程序栏的不透明度设置为 0.99。它足够高,透明度不可见,并且会强制应用程序加载背景。
Looks like the background isn't loaded while the ApplicationBar is hiding. It hides the bar, then load the background, hence the flickering.
Found a workaround: set the opacity of the applicationbar to 0.99. It's high enough for the transparency to be invisible, and it will force the application to load the background.