Page view counter
How to set background color for ComboBox? Subscribe to this thread
Last post 01-05-2009 10:34 AM by kent.zhou. 3 replies.
Sort Posts:
12-30-2008 3:57 PM
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.

kent.zhou

Loading...
Joined on 11-08-2008
Posts 250
12-30-2008 5:45 PM
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

vitor_canova

Loading...
Joined on 11-01-2008
Porto Alegre
Posts 39
01-05-2009 2:33 AM
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.

Amanda Wang - MSFT

Loading...
Joined on 04-30-2007
Posts 1,015
01-05-2009 10:34 AM
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.

 

kent.zhou

Loading...
Joined on 11-08-2008
Posts 250
Microsoft Communities