开发者

Styling WPF/Silverlight ComboBox

I'm trying to figure out how to change the popup part of the Comb开发者_如何学编程oBox 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)


In XamlpadX you can click the styles button and select combobox - the template for the combobox is shown - copy it to your project and experiment.

http://blogs.msdn.com/b/llobo/archive/2008/08/25/xamlpadx-4-0.aspx

You could also take a look at the controlstyle here:

http://msdn.microsoft.com/en-us/library/ms752094.aspx

and controltemplates examples here:

http://archive.msdn.microsoft.com/wpfsamples

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜