The following code run when loading rows to listview what happens only once. My ListView items only have 2 values - "x" and "n". I want the item("cell") with value "x" to have as background color Red. The following code has 2 issues for me: 1) I do not want to specify all columns/items (goodFH, Position, etc) to have the "cell" Red if value = "x" (would like as pseudocode "if current cell value = "x" then Red") 2) args.ItemContainer.Background change the entire row background and not the "cell" I wish!
private void listViewContentChange(ListViewBase sender, ContainerContentChangingEventArgs args)
{
if (((Binding.Car)args.Item).GoodFH == "x")
{
args.ItemContainer.Background = (SolidColorBrush)Application.Current.Resources["Red"];
}
else
{
if (((Binding.Car)args.Item).Position == "x")
{
args.ItemContainer.Background =(SolidColorBrush)Application.Current.Resources["red"];
}
}
}
<DataTemplate x:DataType="data:Car">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
<StackPanel Orientation="Horizontal" Margin="20,20,0,0">
<TextBlock FontSize="18" Text="{x:Bind GoodFH}" HorizontalAlignment="Right" Height="20" Width="158"></TextBlock>
<TextBlock FontSize="18" Text="{x:Bind Position }" HorizontalAlignment="Right" Height="20" Width="78"></TextBlock>
<TextBlock FontSize="18" Text="{x:Bind PathFHfs}" HorizontalAlignment="Right" Height="20" Width="78"></TextBlock>
<TextBlock FontSize="18" Text="{x:Bind PathBHFlSp }" HorizontalAlignment="Right" Height="20" Width="78"></TextBlock>
Any Help? Hope the question is understandable!