- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个正在使用MVVM模式实现的WPF应用程序。在此应用程序中,我试图通过附加属性从PasswordBox中获取密码。但是,我得到了上面看到的错误,并且不确定为什么会得到它。这是我所拥有的:
XAML
<PasswordBox x:Name="passwordTextbox" HorizontalAlignment="Left" Height="31" Margin="316,194,0,0" VerticalAlignment="Top" Width="208"
FontSize="16" IsEnabled="{Binding IsEnabled}"
vm:PasswordBoxAttachedProperty.EncryptedPassword="PasswordSecureString, Mode=Twoway, UpdateSourceTrigger=PropertyChanged" />
using System.Security;
using System.Windows;
namespace QMAC.ViewModel
{
public static class PasswordBoxAttachedProperty
{
public static SecureString GetEncryptedPassword(DependencyObject obj)
{
return (SecureString)obj.GetValue(EncryptedPasswordProperty);
}
public static void SetEncryptedPassword(DependencyObject obj, SecureString value)
{
obj.SetValue(EncryptedPasswordProperty, value);
}
// Using a DependencyProperty as the backing store for MyProperty. This enables animation, styling, binding, etc...
public static readonly DependencyProperty EncryptedPasswordProperty =
DependencyProperty.RegisterAttached("EncryptedPassword", typeof(SecureString), typeof(PasswordBoxAttachedProperty));
}
}
最佳答案
你可能想写
vm:PasswordBoxAttachedProperty.EncryptedPassword=
"{Binding PasswordSecureString, Mode=Twoway, UpdateSourceTrigger=PropertyChanged}"
vm:PasswordBoxAttachedProperty.EncryptedPassword=
"PasswordSecureString, Mode=Twoway, UpdateSourceTrigger=PropertyChanged"
关于c# - 用于 “SecureString”的TypeConverter不支持转换字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36654092/
似乎 TypeConverter.IsValid() 使用了当前的线程文化,但 TypeConverter.ConvertFrom() 没有。 这使得将 TypeConverter.IsValid()
我已将 Room 集成到我的项目中。在这个项目中,一些类在 Kotlin 中,一些在 Java 中。在我使用 Android Studio Ctrl+Alt+Shift+K 组合将我的 Java 文件
我在实现 Room 的类型转换器时出错。 error: Cannot figure out how to save this field into database. You can consider
这很烦人: 我想要这个: 所以我写了一个TypeConverter: public class PenConverter : TypeConverter {
我正在使用 4.0,我正在尝试通过开发一些用于类型转换的辅助方法来让我的生活更轻松。以下方法运行良好。它将从任何字符串转换为其他数据类型。 System.ComponentModel; public
我正在尝试向我的房间数据库中添加一个“图片”字段,其中包含一个名为 MyPicture 的自定义对象,该对象具有以下属性。 private String id; private User user;
我有一个简单的 TypeConverter将逗号分隔的字符串转换为 IEnumerable在调用我的 API 端点时缩短 url。 因此我有一个在客户端设置并传递给服务器的请求对象。所以,在服务器上它
为什么那些返回 true: TypeDescriptor.GetConverter(typeof(double)).CanConvertTo(typeof(double)); TypeDesc
我想创建一个 TypeConverter对于通用类,像这样: [TypeConverter(typeof(WrapperConverter))] public class Wrapper { p
我正在开发一个 IValueConverter 实现,它可以转换 bool? 值。为了通用性,我决定使用 TypeConverter 将输入值转换为 bool?。因为它的主要目的是用作 XAML 绑定
我正在尝试编写这样的标记扩展: [MarkupExtensionReturnType(typeof(Length))] public class LengthExtension : MarkupExt
我正在寻找一种将附加信息传递给 TypeConverter 的方法,以便在不创建自定义构造函数的情况下为转换提供一些上下文。 传递的额外信息将是包含我正在转换的属性的原始对象(在编译时称为接口(int
我目前正在学习 Room Persistence,我只想问一下如何为自定义类创建 TypeConverter? Brand.kt @Parcelize @Entity(tableName = "bra
在我看来,与 TypeConverter 相比,实现隐式运算符非常容易,因此我假设它们不等效,因为框架中普遍存在 TypeConverters(请参阅扩展 FrameworkElement 的任何内容
我有一个 PowerShell 类,我想自动从 string 转换它。 所以我这样定义了一个TypeConverter: class StringToAcmeStateConverter :
到目前为止,为了存储在房间数据库中,我一直在为每个类使用类型转换器。像这样: @SerializedName("sidebar") @Expose @TypeConverters(SidebarCon
我有一个具有以下属性的类: [TypeConverter(typeof(SomeNameEnumValueConvert))] public Example ExampleName { get; se
使用 CsvHelper,当我想要一个自定义解析器时(例如,我想要一个输入字符串为“f”的 MyBooleanConverter 将为 false,“t”将为是真实的”)。但是对于每个类我都必须编写映
我正在研究 XAML 中声明的泛型类型的初始化成员。这是针对 (reduced) generics support在 WPF 4 和 future 的 Silverlight 中。 (我已经在 VS2
我已按照有关如何为自定义类型添加 TypeConverter 的房间文档进行操作,但我的实体类仍然出现错误。我想简单地将 Category 枚举转换为 String,以便房间数据库了解如何存储它。下面
我是一名优秀的程序员,十分优秀!