Dec 1, 2009 at 3:31 AM


Any chance of getting the PasswordBox styled as well? I've tried to duplicate the TextBox style but the background of the PasswordBox remains white while the background of the TextBox is as per the style.


Jun 24, 2011 at 12:40 PM
Edited Jun 24, 2011 at 2:13 PM

Yes, you actually can.

I did it with Dave's Glossy style, but I imagine it's the same with the others, mostly. Worked for me like a charm.

Change the textbox style


 <Style x:Key="{x:Type TextBox}" TargetType="{x:Type TextBox}" > ...
                <ControlTemplate TargetType="{x:Type TextBox}">...


 <Style x:Key="TextBoxDefault" TargetType="{x:Type Control}" > ...
                <ControlTemplate> ...

Then base your TextBox, PasswordBox, RichtTextBox styles upon that style:

    <!-- TextBox -->
    <Style TargetType="{x:Type TextBox}" BasedOn="{StaticResource TextBoxDefault}" />

    <!-- PasswordBox -->
    <Style TargetType="{x:Type PasswordBox}" BasedOn="{StaticResource TextBoxDefault}">
        <Setter Property="PasswordChar" Value="●"/>
        <Setter Property="KeyboardNavigation.TabNavigation" Value="None"/>
        <Setter Property="ScrollViewer.PanningMode" Value="VerticalFirst"/>
        <Setter Property="Stylus.IsFlicksEnabled" Value="False"/>

    <!--RichTextBox -->
    <Style TargetType="{x:Type RichTextBox}" BasedOn="{StaticResource TextBoxDefault}">
            <Style TargetType="{x:Type Paragraph}">
                <Setter Property="Margin" Value="2"/>