I have a ListView that contains my ObservableCollection object as an ItemsSource. This source can send random values. I want to change text block containing values to a specific color depending on the incoming values.
So if incoming values are in the range, text block should stay the same color, and if the value is out of a range, it should become Red.
I've tried with using OnPropetryChange
, but I got nothing...
I also tried to bind to Foreground, but that did not work as well.
<ListView x:Name="ListView" ItemsSource="{Binding ReactorCollection}" HorizontalAlignment="Left" Height="310" Margin="348,10,0,0" VerticalAlignment="Top" Width="254" Grid.RowSpan="2">
<ListView.ItemTemplate>
<DataTemplate>
<Border BorderBrush="Black" BorderThickness="1">
<Grid ShowGridLines="True">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="120"/>
<ColumnDefinition Width="40"/>
<ColumnDefinition Width="110"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Text="{Binding Id, Mode=TwoWay}" TextAlignment="Center" FontSize="15" VerticalAlignment="Center"/>
<TextBlock Grid.Column="1" Text="{Binding Name, Mode=TwoWay}" TextAlignment="Center" FontSize="15" VerticalAlignment="Center"/>
<TextBlock Grid.Column="2" Text="{Binding Value, Mode=TwoWay}" TextAlignment="Center" FontSize="15" VerticalAlignment="Center"/>
</Grid>
</Border>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
This is my XAML, of the ListView in items that it contains, so it's displaying Name, Id, and the Value.
If someone has a bit of advice on how I should implement this, it would help me a lot!