开发者

Override ComboBox Template without theme

开发者 https://www.devze.com 2023-04-04 11:44 出处:网络
I added the ComboBox default ControlTemplate (copied from Blend) to the ResourceDictionary of a UserControl so I could override the ComboBox ControlTemplate. When I added the ControlTemplate I had to

I added the ComboBox default ControlTemplate (copied from Blend) to the ResourceDictionary of a UserControl so I could override the ComboBox ControlTemplate. When I added the ControlTemplate I had to add the following xml namespace:

xmlns:Microsoft_Windows_Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero" 
开发者_开发百科

There are three references in the comboBox default template to objects that are defined in the theme of the PresentationFramework

<Microsoft_Windows_Themes:ButtonChrome ... >
<Microsoft_Windows_Themes:SystemDropShadowChrome ... > 
<Microsoft_Windows_Themes:ListBoxChrome ... > 

Is there a way to remove these classes yet allow the system theme to add them at runtime (as it usually does)? So we don't have to have a hard coded theme in this user control.

Edit: I understand these are not wrappers. However they are pointers to the theme. How to I dynamically pick the theme with just a place holder at compile-time?


You cannot remove the 'mwt' namespace if you use one of these classes in your template. The compiler will complain during compilation. Although the assembly is called the Aero theme, I think you can use these classes on Windows XP without any problems. It's not a wrapper around the Aero controls, but it's a WPF implementation of the look & feel of Windows Vista/7 controls.

0

精彩评论

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

关注公众号