This project has moved and is read-only. For the latest updates, please go here.

Color Picker Binding to Text Foreground

Nov 11, 2010 at 11:16 PM


What is the best way to bind the SelectedColor to selected text foreground in the RichTextBox?  I tried setting "SelectedColor={Binding ElementName=MyRichTextBox, Path=Foreground, Mode=TwoWay}" just to test it out...  but I got an error that the Foreground property was of different type or something.


Nov 11, 2010 at 11:18 PM

Foreground is a type of Brush so you cannot directly bind a Brush to the SelectColor property, which is a type of Color.  You can use an IValueConverter to convert the Color to a Brush.

Nov 12, 2010 at 3:20 AM

Someone just asked a similar question and I provided a simple converter that will work:

Nov 12, 2010 at 4:45 PM

Thanks Brian!