Warm tip: This article is reproduced from serverfault.com, please click

Styling WPF/Silverlight ComboBox

发布于 2011-05-22 22:58:22

I'm trying to figure out how to change the popup part of the ComboBox control. I'm not very familiar with custom styling and templating.

I have a defined popup as in:

<Popup 
      Name="Popup"
      Placement="Bottom"
      IsOpen="{TemplateBinding IsDropDownOpen}"
      .....>
    .... some content
</Popup>

I know that ComboBox control has a named popup called "PART_Popup". How do I replace default implementation with my own?

Thanks

Questioner
user302845
Viewed
0
H.B. 2011-05-23 17:14:37

You could use the loaded event and search for that part in code behind to replace it which might not work since not all PART elements are mandatory. Normally you would copy the exisiting template and change the relevant parts, you can set the template via the ComboBox.Template property.

If you only want to style, rather than significatly change anyhting you can use an implicit style for the popup as well.

Default Templates can be found on MSDN:

WPF ("Default WPF Themes." Link)
Silverlight (Various sub-pages)