.netwpfgradientstop

How to set #FF0B3663 to GradientStop Color


Right now I am doing;

           var backGradient2 = new GradientStop();
           backGradient1.Offset = 0.5;
           backGradient1.Color = Colors.Yellow;

but I need to pass string like #FF0B3663

any idea?

thanks


Solution

  • Use ColorConverter's method ConvertFromString to convert hex string value to actual color value:

    backGradient1.Color = (Color)ColorConverter.ConvertFromString("#FF0B3663");