[英]ApplicaionBar shows black background while hiding or showing
问题是,当我的设备主题设置为暗时,在显示和隐藏ApplicationBar
动画过程中会出现黑色背景。 我要么想要白色,要么不想要背景。
我的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;
}
}
此行为是由于ApplicationBar实际上不是页面的一部分,而是实际上是Shell的一部分。
当包含ApplicationBar时,它将调整应用程序可用空间的大小。 因此,您的页面不会占用ApplicationBar后面的空间,因此默认背景色会显示出来。
更改此设置的最简单方法是不使用不透明的ApplicationBar。 通过向ApplicationBar添加一定程度的透明度(甚至1%),它会显示在页面顶部,而不是页面下方。
这将在隐藏ApplicationBar时解决您的问题,但是您现在需要处理在它后面显示的内容。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.