CodeDocu.com

 

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

WPF Combobox: Dynamically adjust the color of rows

 

The color and background color is in a table.

WPF Combobox: Dynamically adjust the color of rows

 

<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>

 

 

 

 


Software Entwicklung Stuttgart NĂ¼rtingen
Suche Projekte C#, WPF, Windows App,ASP.Net, vb.Net, WinForms, SQL Server, Access, Excel