0

I have a wpf c# app.

I am using a combo box and I set the ItemsSource to my Observable collection.

what I would like is the background of the combo box not to be grey.

This control is housed in a UserControl.

<UserControl x:Class="InformedWorkerClient.UserControls.ucJobStatus"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
         xmlns:local="clr-namespace:InformedWorkerClient.UserControls"
         mc:Ignorable="d" 
         d:DesignHeight="27" d:DesignWidth="300" Background="White">
<Grid Background="White">
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="*"></ColumnDefinition>
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
        <RowDefinition Height="*"></RowDefinition>
    </Grid.RowDefinitions>


    <ComboBox x:Name="cboJobStatus" Grid.Row="0" Grid.Column="0" Background="White"
        DisplayMemberPath="Description" 
        SelectedValuePath="JobStatusRef" 
        SelectedValue="{Binding Path=JobStatus}" SelectionChanged="cboJobStatus_SelectionChanged" />
</Grid>

Additional:

This is what the background looks like after item is selected. I want the background to be white

enter image description here

Andrew Simpson
  • 6,883
  • 11
  • 79
  • 179
  • Possible duplicate of [Combobox background not being applied in windows 8](http://stackoverflow.com/questions/16183746/combobox-background-not-being-applied-in-windows-8) – Kory Gill Jan 03 '16 at 20:04

2 Answers2

1

You cannot do this due to a bug in the ControlTemplate for ComboBox.

Potential solution is to copy/edit the template and create your own.

This question is a duplicate. Perhaps the answer there can be updated with some more information. I searched for wpf cant change background of combobox and the top link is the MSDN answer on how to copy the template but even then the solution is riddled with issues with different Windows versions, aero theming, and does not address situations where users have high contrast turned on, and other accessibility issues.

Community
  • 1
  • 1
Kory Gill
  • 6,993
  • 1
  • 25
  • 33
0

I would recommend to use <ComboBox.ItemContainerStyle> and setup Background to Transparent for the container. Then each item background will be as in the ComboBox.

MWiesner
  • 8,868
  • 11
  • 36
  • 70
Jay Kim
  • 63
  • 3
  • thanks for your reply. It is not quite what I was after. I have augmented my question with an image to make it clearer. thanks – Andrew Simpson Jan 03 '16 at 14:25