Freelance Project Requests info@CodeDocu.de Software Development in C# WPF Asp.Net Core Vba Excel Word SQL-Server EF Linq, UWP Net
#

 

Task: How to dynamically adjust the color of individual lines in a Dropdown List/WPF Combobox?

 

Solution:

You can put within the WPF Combobox via Combox.ItemContainerStyle-> Style ComboboxItem-> with Setter the Foreground and Background Color

 

   <ComboBox.ItemContainerStyle>

               <Style TargetType="ComboBoxItem">

                        <Setter Property="Background" Value="{Binding Farbe}" />

                        <Setter Property="Foreground" Value="{Binding Textfarbe}" />

               </Style>

   </ComboBox.ItemContainerStyle>

 

 

 

In the application, the colors are then tied to the data in a table

 

The color and background color is in a table.

 

<ComboBox x:Name="CbxRevisionsgrund" Width="200" Margin="0,0,5,0"

          SelectionChanged="CbxRevisionsgrund_SelectionChanged"                      >

   <ComboBox.ItemContainerStyle>

               <Style TargetType="ComboBoxItem">

                        <Setter Property="Background" Value="{Binding Farbe}" />

                        <Setter Property="Foreground" Value="{Binding Textfarbe}" />

               </Style>

   </ComboBox.ItemContainerStyle>

                

            </ComboBox>

 

 

 

 

Mobile
»
WPF Combobox: Dynamically adjust the color of rows
»
Linq Combobox: Download dropdown list of data from a table

.

Contact for Jobs, Project Requests: raimund.popp@microsoft-programmierer.de