在C#中设置应用程序条的颜色



我用这样的代码定义我的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);
    }

相关内容

  • 没有找到相关文章

最新更新