0

I'm using the custom ColorPicker control provided by the Extended WPF Toolkit.

I have a configuration file where the application take the color, this color is in string format, like: #FFF0E68C.

Now I'm trying to convert the string in color and valorize the ColorPicker color in this way:

var converter = new BrushConverter();
var brush = (Brush)converter.ConvertFromString("#FFF0E68C");
MyColorPicker.SelectedColor = brush;

but on the last line I get this error:

Implicit conversion from the type 'System.Windows.Media.Brush' in 'System.Windows.Media.Color?'

I doesn't have any Media.Color in brush, how can I fix this? Maybe someone know a better solution for achieve this target?

Thanks in advance.

IlDrugo
  • 1,899
  • 3
  • 12
  • 19

2 Answers2

1

As @Mixim suggested, I simply solve the problem in this way:

var color = (Color)ColorConverter.ConvertFromString(settings.SyncCalendarColor);
MyColorPicker.SelectedColor = color;

Thanks :)

Community
  • 1
  • 1
IlDrugo
  • 1,899
  • 3
  • 12
  • 19
0

May be you donn't need to use BrushConverter and Brush, you should use ColorConverter and Color

Mixim
  • 972
  • 1
  • 11
  • 37