I recently found myself needing to do this and it took longer than expected! Anyway here is my solution!
[source:c-sharp] BrushConverter bc = new BrushConverter();Brush brush;
brush = (Brush)bc.ConvertFrom(ci.Colour);
txtSetterColor.Background = brush;
[/source]
txtSetterColor.Background = (Brush)new BrushConverter().ConvertFrom(ci.Colour);
Indeedy! Nice …
Brush myBrush;
myBrush = new SolidColorBrush ( Color.FromArgb ( 255, 255, 0, 0 ) );
This one works too.
Or the fastest way:
myTextBox.Foreground = new SolidColorBrush ( Color.FromArgb ( 255, 255, 0, 0 ) );
myTextBox.Background = new SolidColorBrush ( Color.FromArgb ( 255, 0, 255, 0 ) );
Happy Coding
Took me time to read all the comments, but I really enjoyed the article. It proved to be very useful to me and I am sure to all the commenters here! It’s always nice when you can not only be informed, but also entertained! I’m sure you had joy writing this article.