views:

94

answers:

1

Well how do i use a template on the TextBox and the PasswordBox atm i have 2 templates defined but thay contain exactly the same content....

+2  A: 

In the class hierarchy, both the controls have only "Control" class in common. So you can make the ControlTemplate for the 'Control' and assign to both. But if you need to have any TextBox/PasswordBox specific TemplateBindings in the template, then this wont work out for you. For example this bellow template will work for both the controls.

<ControlTemplate x:Key="template" TargetType="{x:Type Control}">
<Border BorderThickness="1,1,1,1" BorderBrush="#FF000000">
 <ScrollViewer x:Name="PART_ContentHost" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
</Border>
</ControlTemplate>
Jobi Joy