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
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)
Can you provide an example? It would be very helpful. Like I said, I'm not exactly sure how to make this work. Thanks
Well, the first method is a bad idea because parts are not necessarily mandatory. You posted some code in your question, where is that from? Because if it's from the default template just copy all of it and set it as
ComboBox.Template
, possibly in aStyle.Setter
if you want to apply it to several comboboxes. Just edit the parts you want to be different. (I added some links to my answer if you do not know where to get the default templates.)