【发布时间】:2014-06-02 02:32:49
【问题描述】:
我尝试将 PasswordBox 添加到我的 XAML/C# Windows 商店应用程序中。我为此 PasswordBox 创建了样式,但 VerticalContentAlignment 被忽略了,并且 PasswordBox 的内容显示在顶部。
这是我的 PassworBox 风格:
<Style TargetType="PasswordBox" >
<Setter Property="Height" Value="40"/>
<Setter Property="Width" Value="150"/>
<Setter Property="Background" Value="#cccccc"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="BorderBrush" Value="#cccccc"/>
</Style>
我找到了许多解决方案(主要用于经典 WPF 或 Silverlight),但没有任何帮助。你知道如何处理它吗?谢谢。
【问题讨论】:
-
我尝试了
PasswordBox的样式,对我来说(VS2013、Windows 8、.NET Framework 4.5),密码在垂直和水平方向都居中显示。请说明您如何将样式应用于 PasswordBox,并显示在 PasswordBox 上设置的任何其他属性。 -
我使用的是相同的配置。样式会自动应用于所有密码框(我看到它是因为颜色等)。我尝试直接在 PasswordBox 上设置此属性,但它仍然相同。我的 PasswordBox 看起来很简单:
<PasswordBox Password="{Binding Password}" Grid.Row="2" /> -
这是我的情况:Screenshot
标签: wpf windows-store-apps winrt-xaml