3

I have a list of objects (SensorParameters), for each parameter there is a list of possible values (PossibleValues). When the value of the parameter is changed by user the selected parameter should be displayed in red, however I've only succeeded to make the whole list of possible values and the selected one to become red using ValueChangedToTextColorConverter:

<ItemsControl Grid.Row="1" Grid.Column="2" ItemsSource = "{Binding Sensor.SensorParameters, Mode=TwoWay}">
  <ItemsControl.ItemTemplate>
      <DataTemplate>
          <StackPanel Orientation = "Horizontal">                  
            <Grid>
              <ComboBox
                ItemsSource="{Binding Path=PossibleValues}"
                Foreground="{Binding Path=ValueChanged,
                             Converter={StaticResource ValueChangedToTextColorConverter}}">
                <ComboBox.SelectedItem>
                    <Binding Path="ParameterValue">
                    </Binding> 
                </ComboBox.SelectedItem>      
              </ComboBox>
            </Grid>
          </StackPanel>
        </DataTemplate>
    </ItemsControl.ItemTemplate>
</ItemsControl>

How can I make the selected text only (in the selection box) to become red dependently on ValueChanged?

dymanoid
  • 14,771
  • 4
  • 36
  • 64
Anton
  • 31
  • 3
  • 1
    Please refer to the following thread: https://stackoverflow.com/questions/4672867/can-i-use-a-different-template-for-the-selected-item-in-a-wpf-combobox-than-for – mm8 Jul 16 '18 at 10:00
  • Thanks, actually more relevant question I've found is : https://stackoverflow.com/questions/35724768/how-to-change-the-foreground-of-selected-comboboxitem-with-icon – Anton Jul 18 '18 at 19:37

0 Answers0