windows-phone-7 - 在C#中设置应用程序栏的颜色

标签 windows-phone-7 application-bar

我用这样的代码定义我的 ApplicationBar:

private void BuildApplicationBar()
        {
            // Set the page's ApplicationBar to a new instance of ApplicationBar.
            ApplicationBar = new ApplicationBar();
            ApplicationBar.Opacity = 0.8;
            ApplicationBar.ForegroundColor = Color.FromArgb(0, 138, 204, 34);


            // Create a new button and set the text value to the localized string from AppResources.
            ApplicationBarIconButton CheckInExitAppBarButton = new ApplicationBarIconButton(new Uri("icons/check_in.png", UriKind.Relative));
            CheckInExitAppBarButton.Text = AppResource.CheckInExit;
            ApplicationBar.Buttons.Add(CheckInExitAppBarButton);
            CheckInExitAppBarButton.Click += new EventHandler(CheckInExitAppBarButton_Click);

        }

我可以看到图标的颜色发生了变化,但我看不到它们下面的文字。当我在没有 ApplicationBar.Color 的情况下执行此操作时,我可以同时看到图标 + 文本,但是白色的我不感兴趣

最佳答案

文本使用前景色的 alpha 值,而您将其设置为 0(透明)。改为将其设置为 255 即可:

    private void BuildApplicationBar()
    {
        // Set the page's ApplicationBar to a new instance of ApplicationBar.
        ApplicationBar = new ApplicationBar();
        ApplicationBar.Opacity = 0.8;
        ApplicationBar.ForegroundColor = Color.FromArgb(255, 138, 204, 34);


        // Create a new button and set the text value to the localized string from AppResources.
        ApplicationBarIconButton CheckInExitAppBarButton = new ApplicationBarIconButton(new Uri("icons/check_in.png", UriKind.Relative));
        CheckInExitAppBarButton.Text = AppResource.CheckInExit;
        ApplicationBar.Buttons.Add(CheckInExitAppBarButton);
        CheckInExitAppBarButton.Click += new EventHandler(CheckInExitAppBarButton_Click);

    }

关于windows-phone-7 - 在C#中设置应用程序栏的颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12038954/

相关文章:

c# - 如何在按下时更改应用程序栏按钮的颜色

windows-phone-7 - WP7 : Where do I get calendar, 电话簿和标签应用程序栏图标?

c# - 应用程序栏图标名称

xaml - Windows 8 底部应用栏

c# - 在 Canvas 上绘制单个点的有效方法

c# - 如何为 Windows Phone 棋盘游戏编写简单的 AI 代码?

c# - 如何在不丢失设置的情况下更新我的应用程序?

c# - 从 Windows Phone 应用程序中的图像创建 GIF

c# - JSON不能反序列化为对象,需要数组?