在我的应用程序中,我希望应用程序栏的颜色为白色且完全不透明,与主题无关。到目前为止,我已经对此进行了实验。
ApplicationBar.Opacity = 1;
ApplicationBar.BackgroundColor = Color.FromArgb(52, 50, 2, 181);
结果是具有一定透明度的浅粉色。另外,即使主题很暗,我也想保持相同的主题颜色(浅色主题)图标按钮。我在 WP 商店(主要是 Skype)中看到了这样做的应用程序。答案很高兴。
在我的应用程序中,我希望应用程序栏的颜色为白色且完全不透明,与主题无关。到目前为止,我已经对此进行了实验。
ApplicationBar.Opacity = 1;
ApplicationBar.BackgroundColor = Color.FromArgb(52, 50, 2, 181);
结果是具有一定透明度的浅粉色。另外,即使主题很暗,我也想保持相同的主题颜色(浅色主题)图标按钮。我在 WP 商店(主要是 Skype)中看到了这样做的应用程序。答案很高兴。
两种方式,无论是在 XAML 中:
<phone:PhoneApplicationPage.ApplicationBar>
<shell:ApplicationBar BackgroundColor="White" ForegroundColor="Black">
<shell:ApplicationBar.Buttons>
<shell:ApplicationBarIconButton Text="A button" IconUri="/Assets/AppBar/new.png" />
</shell:ApplicationBar.Buttons>
</shell:ApplicationBar>
</phone:PhoneApplicationPage.ApplicationBar>
或者在后面的代码中:
using System.Windows.Media;
...
ApplicationBar.ForegroundColor = Colors.Black; // Icon and text color
ApplicationBar.BackgroundColor = Colors.White; // Application bar background color
本质上,BackgroundColor
设置应用程序栏的背景颜色并ForegroundColor
设置图标和文本颜色。无论主题设置如何,设置这些都将保留该值。
您不需要设置opacity
,因为默认值为 1(完全不透明)。