Binding PasswordBox control to create user.

4 posts, 1 answers
  1. Alan
    Alan avatar
    107 posts
    Member since:
    Oct 2010

    Posted 21 Mar 2011 Link to this post

    Hi,

    I'm trying to use this control for user management, I am aware that you're not supposed to bind to PasswordBox field, and I do not intend to, but I would like to have the field there when you're going to insert a new user or edit a current user (in the case of edit it would be an empty text field).

    How would you go about achieving this?

    Thanks,
    Daryl
  2. Vanya Pavlova
    Admin
    Vanya Pavlova avatar
    2019 posts

    Posted 22 Mar 2011 Link to this post

    Hello Daryl,

     
    In this case you have to manually define the fields in RadDataForm and set the PasswordBox as its content as shown below:

    <telerik:DataFormDataField  Label="PersonalInfo:">
                         <PasswordBox Password="{Binding PersonalInfo,Mode=TwoWay}" PasswordChar="*"/>
    </telerik:DataFormDataField>

    Also you may check our online demos and documentation for more information.


    Kind regards,
    Vanya Pavlova
    the Telerik team
  3. UI for WPF is Visual Studio 2017 Ready
  4. Alan
    Alan avatar
    107 posts
    Member since:
    Oct 2010

    Posted 22 Mar 2011 Link to this post

    Hi Vanya,

    The problem is that Password doesn't have a DependencyProperty. So when you try to bind the password, you'll get this error:

    A 'Binding' cannot be set on the 'Password' property of type 'PasswordBox'. A 'Binding' can only be set on a DependencyProperty of a DependencyObject.

    Hence my original question.

    Thank you for your help,
    Daryl
  5. Answer
    Vanya Pavlova
    Admin
    Vanya Pavlova avatar
    2019 posts

    Posted 22 Mar 2011 Link to this post

    Hello Daryl,

     
    I have spent some time to investigate this case. The main reason that the PasswordBox control for both WPF/Silverlight does not expose  a DependencyProperty for the Password property is due to security reasons and generally should be avoided. I have found two interesing threads which might be useful for you to fetch this limitation:
                                                                    "PasswordBox and Binding"
                                                              "PasswordBox and Binding MVVM"  


    In case you need any further assistance, please let me know.

    Kind regards,
    Vanya Pavlova
    the Telerik team
Back to Top