0

So I have this xaml line in my WPF project:

<PasswordBox x:Name="passwd" materialDesign:HintAssist.HelperText=""
 materialDesign:HintAssist.Hint="Password" materialDesign:HintAssist.Background="#1A1F25"
 materialDesign:HintAssist.Foreground="White" Padding="10" Margin="0 0 0 20"/>

And by clicking a button, my C# code has to check if the password is inputed correctly, otherwise it has to change HelperText into "Wrong". I have tried smth like this, but without any succes:

else if (user_password.Password.Length > 32 || user_password.Password.Length < 10) 
        {
            MaterialDesignThemes.Wpf.HintAssist.HelperTextProperty = "Wrong!";
        }

1 Answers1

0

The HelperText property of HintAssist is not a static property, so you can't change it like that. Insted of that you should use SetHelperText method for your PasswordBox which you can find by name:

// if user_password is not an isntance of PasswordBox then you need to retrieve it first
if (passwordBox.Password.Length > 32 || passwordBox.Password.Length < 10) 
{
    MaterialDesignThemes.Wpf.HintAssist.SetHelperText(user_password, "Wrong!");
}
Vadim Martynov
  • 8,602
  • 5
  • 31
  • 43