Skip to content

Cannot clear UnsafePassword in plaintext state by vm code #645

Closed

Description

@JeremyWu917

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 = ""; }

Activity

  1. JeremyWu917 commented on Jan 25, 2021

    @JeremyWu917
    ContributorAuthor

    @ghost1372
    pls help to check and advise
    many thx

  2. ghost1372 commented on Jan 25, 2021

    @ghost1372
    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}" />
    
  3. JeremyWu917 commented on Jan 25, 2021

    @JeremyWu917
    ContributorAuthor

    @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

  4. JeremyWu917 commented on Jan 27, 2021

    @JeremyWu917
    ContributorAuthor

    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));
            }
        }`
    
  5. NaBian commented on Jan 31, 2021

    @NaBian
    Member

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

  6. JeremyWu917 commented on Feb 1, 2021

    @JeremyWu917
    ContributorAuthor

    @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

  7. NaBian commented on Feb 1, 2021

    @NaBian
    Member

    还是无法复现
    demo

  8. added a commit that references this issue on Mar 28, 2024
    3b43a12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    🐛 bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      ⌂ 换网址