Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > Avalon

Vista - WPF combobox background

 
 
Old 06-09-2007   #1 (permalink)
Michael Jackson


 
 

WPF combobox background

The entire UI of my new application mimics the UI of Microsoft Expression
Blend.
I'm trying to get the background of the combobox to be the very dark grey,
but can't make it happen.

How can I change the background of a combobox, either IsEditable = true or
false.

Thanks



My System SpecsSystem Spec
Old 06-11-2007   #2 (permalink)
David Cater


 
 

Re: WPF combobox background

It appears that the background of the collapsed part of the combo box is
easily set using the Background attribute. I assume you're referring to the
popup part of the combo box. I haven't experimented with it yet, but I know
that the ComboBox control uses the PART_* architecture for identifying the
popup element that gets brought up when you expand the ComboBox. It looks
for a part called "PART_Popup". That is a <Popup> element.

So what does that mean for you? If you were to create your own control
template for the ComboBox, you would want to make sure you have a <Popup>
element in your template called PART_Popup. That would have a background
color set to be the same as the background color for the combo box itself.
I'm not sure how you would define PART_Popup itself, although it's possible
you could just define the Popup with nothing inside it and the control would
do the work of binding it to the items in the combo box.

Like I said, I haven't tried any of that. But it might get you started in
the right direction.

David Cater

"Michael Jackson" <michaeldjackson@suddenlink.net> wrote in message
news:466a2676$0$4303$bbae4d71@news.suddenlink.net...
> The entire UI of my new application mimics the UI of Microsoft Expression
> Blend.
> I'm trying to get the background of the combobox to be the very dark grey,
> but can't make it happen.
>
> How can I change the background of a combobox, either IsEditable = true or
> false.
>
> Thanks
>


My System SpecsSystem Spec
Old 06-11-2007   #3 (permalink)
David Cater


 
 

Re: WPF combobox background

Scratch that. I was doing some experiments myself, and it's actually much
easier than that. You don't have to completely override the control
template, which is the direction my first response was going. All you have
to change is the ItemsPanel, which controls how the items in the ComboBox
are displayed on popup:

<ComboBox Background="DarkGray" Foreground="White">
<ComboBox.ItemsSource>
<coll:ArrayList>
<sys:String>A</sys:String>
<sys:String>B</sys:String>
<sys:String>C</sys:String>
</coll:ArrayList>
</ComboBox.ItemsSource>
<ComboBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Background="DarkGray"/>
</ItemsPanelTemplate>
</ComboBox.ItemsPanel>
</ComboBox>

David Cater


"David Cater" <xiard@mindspring.com> wrote in message
news:uAi%23lBDrHHA.4100@TK2MSFTNGP06.phx.gbl...
> It appears that the background of the collapsed part of the combo box is
> easily set using the Background attribute. I assume you're referring to
> the popup part of the combo box. I haven't experimented with it yet, but
> I know that the ComboBox control uses the PART_* architecture for
> identifying the popup element that gets brought up when you expand the
> ComboBox. It looks for a part called "PART_Popup". That is a <Popup>
> element.
>
> So what does that mean for you? If you were to create your own control
> template for the ComboBox, you would want to make sure you have a <Popup>
> element in your template called PART_Popup. That would have a background
> color set to be the same as the background color for the combo box itself.
> I'm not sure how you would define PART_Popup itself, although it's
> possible you could just define the Popup with nothing inside it and the
> control would do the work of binding it to the items in the combo box.
>
> Like I said, I haven't tried any of that. But it might get you started in
> the right direction.
>
> David Cater
>
> "Michael Jackson" <michaeldjackson@suddenlink.net> wrote in message
> news:466a2676$0$4303$bbae4d71@news.suddenlink.net...
>> The entire UI of my new application mimics the UI of Microsoft Expression
>> Blend.
>> I'm trying to get the background of the combobox to be the very dark
>> grey, but can't make it happen.
>>
>> How can I change the background of a combobox, either IsEditable = true
>> or false.
>>
>> Thanks
>>

>


My System SpecsSystem Spec
 

Thread Tools



Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46