简体   繁体   English

在UWP中设置PasswordBox的对齐方式

[英]Setting the alignment of a PasswordBox in UWP

I'm trying to create a PasswordBox that looks like this 我正在尝试创建一个看起来像这样的PasswordBox

在此处输入图片说明

It has the password characters aligned to the center. 它的密码字符居中对齐。

How do I modify the ControlTemplate to do this? 如何修改ControlTemplate来做到这一点? I have seen it and it looks quite complex. 我已经看过了,看起来很复杂。

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: 在模板中,您将找到一个名为“ ContentElement”的ScrollViewer ,用于显示内容,只需向其添加HorizontalAlignment="Center" ,如下所示:

<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"/>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM