c# - 如何更改 Windows Phone 应用程序栏的颜色?

标签 c# windows-phone-7 windows-phone-8 application-bar

在我的应用程序中,我希望应用程序栏的颜色为白色且完全不透明,与主题无关。到目前为止,我已经对此进行了试验。

ApplicationBar.Opacity = 1;
ApplicationBar.BackgroundColor = Color.FromArgb(52, 50, 2, 181);

结果是带有一些透明度的淡粉色。另外,即使主题是深色的,我也想保留相同的主题颜色(浅色主题)图标按钮。我在 WP Store(主要是 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 设置图标和文本颜色。无论主题设置如何,设置这些值都会保留值。

您不需要设置不透明度,因为默认值为 1(完全不透明)。

关于c# - 如何更改 Windows Phone 应用程序栏的颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23973429/

相关文章:

c# - Windows 8 应用程序/加载屏幕

c# - 使用 ILGenerator 生成方法

windows-phone-7 - WP7 工具包更新从 LongListSelector 中删除了 GetItemsInView()

visual-studio-2010 - Windows Phone 7 SDK 和 Visual Studio 2010 RTM

c# - Windows Phone 8 通知和后台任务

c# - 页面导航WP8.1

c# - 在 XAML 堆栈布局中插入 cs stacklayout

c# - 从 if/else 语句中获取值?

silverlight - Windows Phone 7,创建可序列化的类

c++ - Visual Studio 错误 : LNK1104: cannot open file 'kernel32.lib' - only in WP8 projects/Win32 builds