Skip to main content

Microsoft Silverlight

Unanswered Question How to set background color for ComboBox?RSS Feed

(0)

kent.zhou
kent.zhou

Member

Member

109 points

393 Posts

How to set background color for ComboBox?

How to set background color only for dropdown list box for ComboBox not for the text field? I tried to set Property Background and it seemed ineffective.

vitor_canova
vitor_ca...

Member

Member

152 points

41 Posts

Re: How to set background color for ComboBox?

I dont't know exacly you need. If you show me a image with your wish. But if I need to change the  appearance of a control I open with Expression Blend 2 and select him. After that I do a reverse click on control in "Objects and Timeline", "Edit Control Parts (Template)", "Edit a Copy" and select to do this in application. Like this:

 ComboBox

 

The post helped you? mark as answered

Vitor Canova Weingaertner
Go to my blog
Go to my Site

Amanda Wang - MSFT
Amanda W...

All-Star

All-Star

17241 points

1,466 Posts

Re: How to set background color for ComboBox?

 Hi Kent,

If you want the dropdown list has the different background color with the text field, you can set the ComboBoxItem's Background, below code work fine on our labs:

<ComboBox Height="40" Margin="49,43,150,0" VerticalAlignment="Top" Background="#FF0F51EB">
          <ComboBoxItem Content="Item1" Background="#FFEC1313"/>
          <ComboBoxItem Content="Item1" Background="#FF24E643"/>
          <ComboBoxItem Content="Item1" Background="#FF8B2CE4"/>
      </ComboBox>

Amanda Wang
Microsoft Online Community Support

Please remember to mark the replies as answers if they help and unmark them if they provide no help.

kent.zhou
kent.zhou

Member

Member

109 points

393 Posts

Re: How to set background color for ComboBox?

Thanks for your information. My ComboBox uses template for the list item. It looks like:

 <ComboBox x:Name="xMyList" Height="20" Style="{StaticResource FormComboBox}">
    <ComboBox.ItemTemplate>
        <DataTemplate>
            <StackPanel Orientation="Horizontal">
              <TextBlock Width="150" Text="{Binding Path=myName}" VerticalAlignment="Center" FontSize="10" />
            </StackPanel>
        </DataTemplate>
    </ComboBox.ItemTemplate>
</ComboBox>

For template there is no backgroupd property. I can set background for Stackpanel, but that only be effective for the list item, between the item in the list , there is a gap with another color. What I want is set the a background color for whole box for the dropdown(Default is white), not each item in the list.

 

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities