views:

77

answers:

2

I'm working on a control template for an inherited TextBox class. I'd like to use this template to add additional controls with the ScrollViewer. I can achieve that goal just fine, what I can't do recreate the border in such away that it matches the Windows look and feel.

I have Windows Classic as my theme on XP. Textboxes are typically shown with the standard inset border style. With the XP Fischer Price theme, borders of textbox are a flat style and light blue.

Is there any way of specifying something like this in the template? Ideally it would use the theme default (grey inset for Classic, flat and light blue for fischer price theme).

A: 

You will have to provide a separate ControlTemplate for each known theme. There is no generic way to create a theme-agnostic ControlTemplate. Infact WPF itself maintains separate ControlTemplates for each official theme (excpet the Zune theme, where WPF falls back to battleship gray).

bitbonk
A: 

I'm not sure if this will work as I am not sure what your setup is. I also don't know if you are concerned about changing themes on the fly. You can try to set the style for your text box class to have

BasedOn="{DynamicResource {x:Type TextBox}}"
Craig Suchanec