C
C#3y ago
Jelles

Binding Colors to WPF Window

My model contains a field with a Color value that I am trying to bind to in my MainWindow.xaml. My issue is that when I do this nothing gets drawn... If I put the value on AQUA or something by removing the binding it works fine...
7 Replies
Jelles
JellesOP3y ago
Here you can see my Fill has Aqua and it works like this But when I add {Binding Color} it does not
Jelles
JellesOP3y ago
Jelles
JellesOP3y ago
It has to do with the color cause the other bindings work fine on the Elipse field. If anyone has a solution let me know! Thanks
Alexicon
Alexicon3y ago
WPF does not use colors but rather "Brushes" to draw. You would want a "SolidColorBrush" in this case:
Alexicon
Alexicon3y ago
Alexicon
Alexicon3y ago
you can pass your color into the solidcolorbrush's constructor
Jelles
JellesOP3y ago
Perfect thanks for the solution!

Did you find this page helpful?