Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot clear UnsafePassword in plaintext state by vm code #645

Closed
JeremyWu917 opened this issue Jan 25, 2021 · 7 comments
Closed

Cannot clear UnsafePassword in plaintext state by vm code #645

JeremyWu917 opened this issue Jan 25, 2021 · 7 comments
Labels
🐛 bug Something isn't working

Comments

@JeremyWu917
Copy link
Contributor

Describe the bug
After binding UnsafePassword to hc:PasswordBox, the value of UnsafePassword cannot be cleared by backend code in plaintext state, but can be cleared by ClearButton in frontend. And in ciphertext state, everything is ok.

Expected behavior
The value should be cleared regardless of whether it is in plaintext or ciphertext state

Screenshots
issue_passwordbox_bug

Environment (please complete the following information):

  • .net: [NET 5.0]
  • IDE [VS2019 16.8.4]
  • HC Version [3.0.0]

Additional context
Here is the partial code

  • .XAML
    <hc:PasswordBox hc:InfoElement.Placeholder="请输入密码" IsSafeEnabled="False" ShowClearButton="True" ShowEyeButton="True" UnsafePassword="{Binding Password}" />
  • VM
    private string _Password;
    public string Password { get { return _Password; } set { _Password = value; this.RaisePropertyChanged(nameof(Password)); } }
    public DelegateCommand CancelCommand { get; set; } private void Cancel(object parameter) { Password = ""; }
@JeremyWu917
Copy link
Contributor Author

@ghost1372
pls help to check and advise
many thx

@ghost1372
Copy link
Member

@JeremyWu917
I think it is a binding problem, You can use the internal command to clear

<Button Content="clear" Command="hc:ControlCommands.Clear" CommandTarget="{Binding ElementName=xx}"/>
        <hc:PasswordBox Name="xx" hc:InfoElement.Placeholder="请输入密码" IsSafeEnabled="False" ShowClearButton="True" ShowEyeButton="True" UnsafePassword="{Binding Password}" />

@JeremyWu917
Copy link
Contributor Author

@ghost1372

Thanks for your reply.
It's works for me if I use the the internal command to clear, but in this case I wanna clear all params not just one element, and most of the time there is more than one element to clear.
And it make no sence cause other controls with the same binding method do not have this problem.
Thanks

@NaBian NaBian added the 🐛 bug Something isn't working label Jan 26, 2021
@NaBian NaBian closed this as completed in 3b43a12 Jan 26, 2021
@JeremyWu917
Copy link
Contributor Author

Hi @NaBian @ghost1372

There is still a concern not about Clear , it is Set value, cause when I set ShowEyeButton as true, I cannot set UnsafePassword in vm, means FrameworkPropertyMetadataOptions.BindsTwoWayByDefault not work any more.
Please review, thanks.

BTW, I declare Password in vm as below

   `private string _Password;
    public string Password
    {
        get { return _Password; }
        set
        {
            _Password = value;
            this.RaisePropertyChanged(nameof(Password));
        }
    }`

@NaBian
Copy link
Member

NaBian commented Jan 31, 2021

i can not reproduce your problem, can you provide a demo.

@JeremyWu917
Copy link
Contributor Author

@NaBian

Thanks for your replay.

Here is the demo.
issue_passwordbox_sample

I cannot copy value from param one to param two when passwordbox's eyes on, means I cannot perform a set property.

Thanks

@NaBian
Copy link
Member

NaBian commented Feb 1, 2021

还是无法复现
demo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants