- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有以下样式定义:
<!-- Border -->
<Style x:Key="MyControlBorder" TargetType="{x:Type Border}">
<Setter Property="BorderBrush" Value="DarkKhaki" />
<Setter Property="Background" Value="White" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="CornerRadius" Value="10" />
</Style>
<!-- TextBox -->
<Style x:Key="MyTextBox" TargetType="{x:Type TextBox}">
<Setter Property="Height" Value="30" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TextBoxBase}">
<Border Name="TextBoxBorder" Style="{StaticResource MyControlBorder}">
<ScrollViewer x:Name="PART_ContentHost"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!-- PasswordBox -->
<Style x:Key="MyPasswordBox" TargetType="{x:Type PasswordBox}">
<Setter Property="Height" Value="30" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Control}">
<Border Name="Border" Style="{StaticResource MyControlBorder}">
<ScrollViewer x:Name="PART_ContentHost" />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<TextBox Grid.Row="0" Style="{StaticResource MyTextBox}" />
<PasswordBox Grid.Row="1" Style="{StaticResource MyPasswordBox}" />
</Grid>
最佳答案
不知何故 Border
内ControlTemplate
的 PasswordBox
不带MyControlBorder
风格。
修改时MyPasswordBox
这样的风格......然后它会起作用。
<Style x:Key="MyPasswordBox" TargetType="{x:Type PasswordBox}">
<Setter Property="Height" Value="30" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Control}">
<Border Name="Border" BorderBrush="DarkKhaki" Background="White" BorderThickness="1" CornerRadius="10">
<ScrollViewer x:Name="PART_ContentHost" />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
MyControlBorder
不适用。当你摆脱
MyTextBox
时它甚至不起作用风格。那么你只剩下
MyControlBorder
和
MyPasswordBox
......它也不起作用。
关于wpf - PasswordBox 不假设样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16911345/
我有以下样式定义:
这似乎是 Windows Phone 中的明显疏忽。 控件不允许指定 InputScope . 我需要显示 PasswordBox作为自定义密码输入屏幕的一部分(例如图像和按钮),并显示数字键盘以仅允
我在这里找到了一些关于这个问题的信息,但不知何故我并没有真正得到它;-) 从我所读到的内容来看,由于安全原因,PasswordBox 的密码不能绑定(bind)到属性,即保留普通密码在内存中。 我的模
我一直很欣赏 Josh Smith 建立他的 sample application 的方式。 . 而且我还尝试模拟他的应用程序的 ViewModels 实现 IDataErrorInfo 属性的方式,
我有一个需要让用户创建密码的应用程序。因此,在输入密码时需要测试各种规则。 这些规则很典型——值必须有一定的长度,有一个大,一个小,包括一些特殊字符等。 但是,由于这是一个使用 PasswordBox
我有一个密码框,我想获取输入数据以检查验证。 我的密码箱c#代码 public void textBox2_TextInput(object sender, TextCompositionEven
我正在使用最新的 MahApps WPF 工具包,但在将我自己的样式应用到它的控件(准确地说是 PasswordBox)上时遇到了一些麻烦。 我在一个单独的 .xaml 文件中定义了样式,该文件包含在
我不知道有人知道如何在 PasswordBox 中显示密码。已阅读过您可以将文本框绑定(bind)到密码框,但这不是另一种方法吗? 最佳答案 如果您希望密码可见,您应该使用文本框。密码框的唯一功能是屏
所以我有一个密码框: 但是我也有一个明确的功能,其中包含: Password = null 我遇到的问题是 PlaceholderText 没有恢复,而是该框留空。 这是一个错误还是我遗漏了什么?
我正在尝试对 PasswordBox 进行验证。为了进行验证,我遵循了这个 link ,显示了如何在 TextBox 上进行验证。 问题来自 PasswordBoxes。因为它的 Password 出
最近我已经问了几个关于 PasswordBox 的问题,但我的问题的核心是,我需要一种极其安全的方式来将非常敏感的信息输入到我的 .Net 应用程序中。 开箱即用,WPF PasswordBox 是获
为什么我无法将焦点设置在我的 PasswordBox 控件上? C#: public Login() { InitializeComponent(); _password.Focus();
我有一个密码框。 PasswordBox输入完成后如何获取输入值? 最佳答案 您可以从 Password 属性中获取它。 关于C# 如何从 PasswordBox 中获取文本值?,我们在Stack O
创建包含 PasswordBox 的 WPF 应用程序时控制,我试图设置PasswordChar显示“ 使用这段代码时,报如下错误: Error 1 The value " 您可以在这篇 MSDN 文
我这里有一些概念问题。我知道如何选择 TextBox 或 PasswordBox 中的所有文本。通过 GotKeyboardFocus 和 PreviewMouseLeftButtonDown 事件,
我只是偶然发现 WPF PasswordBoxes 的 Password 属性出于安全原因 是不可绑定(bind)的,这使得使用它们相当在 MVVM 上下文中很麻烦。类似 https://stacko
我正在尝试显示 PasswordBox 的 Validation.ErrorTemplate。但是,它没有显示。在同一表单上,我有一个用户名 TextBox 并且正确显示了 ErrorTemplate
我有一个 UWP 应用程序,它使用 PasswordBox 控件进行模糊文本输入。密码的有效字符因实例而异,并且在运行时为 ViewModel 层所知。我希望能够在用户键入无效字符时过滤掉它们。这样做
我读到 WPF PasswordBox 中的密码没有用于绑定(bind)密码的依赖属性出于安全原因。尽管如此,还是有ways to bind it anyway . MVVM 模式的用户需要这种数据绑
我有一个现有的 SecureString我想放入 PasswordBox 不泄露 .Password。这可以做到吗?例如: tbPassword.SecurePassword = DecryptStr
我是一名优秀的程序员,十分优秀!