-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Labels
🏭 enhancementNew feature or requestNew feature or request
Description
Hi brother,
There is error message that “Passwordbox no longer supports additional attributes built by the blend SDK” when I change control from PasswordBox to HC control - hc:PasswordBox. Is there anyone catch the same issue?
Thx.
Windows10 1809
Microsoft Visual Studio Enterprise 2019 Version 16.6.2
Microsoft .NET Framework Version 4.8.03761
HC Control Version 2.5.0.2
BTH,the screenshot below is the current code.
`public static class PasswordBoxHelper
{
public static readonly DependencyProperty PasswordProperty =
DependencyProperty.RegisterAttached("Password",
typeof(string), typeof(PasswordBoxHelper),
new FrameworkPropertyMetadata(string.Empty, OnPasswordPropertyChanged));
private static void OnPasswordPropertyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
{
PasswordBox passwordBox = sender as PasswordBox;
string password = (string)e.NewValue;
if (passwordBox != null && passwordBox.Password != password)
{
passwordBox.Password = password;
}
}
public static string GetPassword(DependencyObject dp)
{
return (string)dp.GetValue(PasswordProperty);
}
public static void SetPassword(DependencyObject dp, string value)
{
dp.SetValue(PasswordProperty, value);
}
}
public class PasswordBoxBehavior : Behavior<PasswordBox>
{
protected override void OnAttached()
{
base.OnAttached();
AssociatedObject.PasswordChanged += OnPasswordChanged;
}
private static void OnPasswordChanged(object sender, RoutedEventArgs e)
{
PasswordBox passwordBox = sender as PasswordBox;
string password = PasswordBoxHelper.GetPassword(passwordBox);
if (passwordBox != null && passwordBox.Password != password)
{
PasswordBoxHelper.SetPassword(passwordBox, passwordBox.Password);
}
}
protected override void OnDetaching()
{
base.OnDetaching();
AssociatedObject.PasswordChanged -= OnPasswordChanged;
}
}`
lindexi
Metadata
Metadata
Assignees
Labels
🏭 enhancementNew feature or requestNew feature or request
