I have following rangeobservablecollection:
private readonly RangeObservableCollection<coll> _coll;
where coll is bunch of checkboxes that i am adding to this collection. I want to change the foreground color of the checkbox on particular add like this:
_coll.Add( info );
Is there a way to change the color of this?
XAML code:
<StackPanel Orientation="Horizontal">
<CheckBox Margin="0,0,3,0" Foreground="{Binding Foreground"}">
<CheckBox.IsChecked>
<Binding Path="IsSelected"
Mode="TwoWay">
<Binding.RelativeSource>
<RelativeSource Mode="Parent" />
</Binding.RelativeSource>
</Binding>
</CheckBox.IsChecked>
</CheckBox>
<ContentPresenter />
</StackPanel>
You can use a template on your ui object that binds the foreground color to a SolidColorBrush property on coll class.
your class definition will look something like this:
then you can change the foreground:
There’s a lot of variations you can use here to achieve the same effect: converters, INPC…