Reputation: 13982
I'm trying to create a PasswordBox that looks like this
It has the password characters aligned to the center.
How do I modify the ControlTemplate to do this? I have seen it and it looks quite complex.
Upvotes: 2
Views: 314
Reputation: 29792
In the template you will find a ScrollViewer
called "ContentElement" which is used to display the content, just add HorizontalAlignment="Center"
to it like so:
<ScrollViewer x:Name="ContentElement"
VerticalAlignment="Center"
HorizontalAlignment="Center"
AutomationProperties.AccessibilityView="Raw"
HorizontalScrollMode="{TemplateBinding ScrollViewer.HorizontalScrollMode}"
HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}"
IsTabStop="False"
IsHorizontalRailEnabled="{TemplateBinding ScrollViewer.IsHorizontalRailEnabled}"
IsVerticalRailEnabled="{TemplateBinding ScrollViewer.IsVerticalRailEnabled}"
Margin="{TemplateBinding BorderThickness}"
Padding="{TemplateBinding Padding}"
Grid.Row="1"
VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}"
VerticalScrollMode="{TemplateBinding ScrollViewer.VerticalScrollMode}"
ZoomMode="Disabled"/>
Upvotes: 4