I have a listbox which is bounded to an observable collection. The elements in the collection contain a variable called color. My listbox’s items are already bounded to the collection, but how do I also bind the items font color to that? I already have a data template which works fine replacing item’s name with the color name like this
<DataTemplate x:Key="myListBox">
<TextBlock Padding="0,0,10,0"
Text="{Binding Path=Color, Mode=Default}"/>
</DataTemplate>
but I can’t seem to find which property I have to set in order to bind the color.
Not sure which colour you’re referring to, but this will set the background and text/foreground colours.
EDIT: dependancy prop –
Replace CLASSNAMEHERE with the name to the class you’re putting it in, ie the viewmodel class or codebehind class name.
use: