How to assign a hex color?

jennyliu835 221 Reputation points
2020-09-21T00:04:16.477+00:00

Hi Peter + Daisy,

How to replace "Orange" with "#FFBF72FF" on line 5? Thanks.

  1. namespace WpfApp2.general_pages
  2. {
  3. class Pages_ViewModel : ICommand, INotifyPropertyChanged
  4. {
  5. public Color Tb3BackgroundColor { get; set; } = Colors.Orange;
  6. public Visibility Tb1Visibility { get; set; } = Visibility.Hidden;
  7. public Visibility Tb2Visibility { get; set; } = Visibility.Hidden;
  8. public Visibility Tb3Visibility { get; set; } = Visibility.Hidden;
  9. ...
Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,710 questions
0 comments No comments
{count} votes

Accepted answer
  1. DaisyTian-1203 11,621 Reputation points
    2020-09-21T03:51:00.837+00:00

    Try to use public Color Tb3BackgroundColor { get; set; } = (Color)System.Windows.Media.ColorConverter.ConvertFromString("#FFBF72FF"). And there is an answer(How do I get the color from a hexadecimal color code using .NET) which is related to your question ?


    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful