Skip to main content

Microsoft Silverlight

Answered Question Databinding with PasswordBoxRSS Feed

(0)

murtaza.dharwala
murtaza....

Participant

Participant

1659 points

378 Posts

Databinding with PasswordBox

hello I am Trying to bindthe  Password Property of my passwordbox to the Password property of my User object like this

Password="{Binding Password}"

but it is giving some error,

AG_E_RUNTIME_MANAGED_UNKNOWN_ERROR at System.windows.application.loadcomponent(object component,Uri ResourceLocator).

 

but if i set the Password Property from the code behind it work fine and displays the password chars on the UI.

UserPasswordBox.Password = CurrentUser.Password;

where UserPasswordBox is my PasswordBox Control

Murtaza Dharwala
Diaspark Inc.
www.diaspark.com
email:murtaza.dharwala@diaspark.com


Please remember to click “Mark as Answer” on the post that helps you

ken tucker
ken tucker

All-Star

All-Star

16324 points

2,493 Posts

Re: Databinding with PasswordBox

You cannot bind to the password field.  I personally do not see the need for it.  The idea of a password is confirm identy. If the user does not have to enter the password why have one.

murtaza.dharwala
murtaza....

Participant

Participant

1659 points

378 Posts

Re: Re: Databinding with PasswordBox

I need the password field for user to be able to create an id and also at later stage to Update the Password

Murtaza Dharwala
Diaspark Inc.
www.diaspark.com
email:murtaza.dharwala@diaspark.com


Please remember to click “Mark as Answer” on the post that helps you

Rob Smith
Rob Smith

Member

Member

22 points

37 Posts

Re: Re: Databinding with PasswordBox

murtaza, were you able to find a workaround for this issue? Thank for any feedback.

murtaza.dharwala
murtaza....

Participant

Participant

1659 points

378 Posts

Re: Re: Re: Databinding with PasswordBox

work around is to manually set the field. and take care if it is changed or not

Murtaza Dharwala
Diaspark Inc.
www.diaspark.com
email:murtaza.dharwala@diaspark.com


Please remember to click “Mark as Answer” on the post that helps you

mchlsync
mchlsync

Star

Star

14606 points

2,730 Posts

Silverlight MVP

Re: Databinding with PasswordBox

YOu can use the attached property for that. I will give you the sample on this weekend. If it's urgent, mail me ..

(If this has answered your question, please click on "Mark as Answer" on this post. Thank you!)

Regards,
Michael Sync
Silverlight MVP

Blog : http://michaelsync.net


murtaza.dharwala
murtaza....

Participant

Participant

1659 points

378 Posts

Re: Re: Databinding with PasswordBox

what benifit i will get using the attached property instead of normally setting the Password property from code in code behind

Murtaza Dharwala
Diaspark Inc.
www.diaspark.com
email:murtaza.dharwala@diaspark.com


Please remember to click “Mark as Answer” on the post that helps you

mchlsync
mchlsync

Star

Star

14606 points

2,730 Posts

Silverlight MVP
Answered Question

Re: Re: Databinding with PasswordBox

I have sent my file to Rob and he said that it's working for his case. :)

murtaza.dharwala:

what benifit i will get using the attached property instead of normally setting the Password property from code in code behind

If you are into design and pattern, you won't use code-behind file anymore. For example: Let's say you are using MVVM or MVP pattern in your project. You will bind the View with ViewModel or Presenter directly from your view. The most of logic will go to ViewModel Or Presenter so you won't use the code-behind file. The advatnage of using pattern is that you will have very clean design and good seperation of UI and Logic. and testablity.. You can unit-test the ViewModel or Presetner.

(If this has answered your question, please click on "Mark as Answer" on this post. Thank you!)

Regards,
Michael Sync
Silverlight MVP

Blog : http://michaelsync.net


MComeauS2S
MComeauS2S

Member

Member

282 points

154 Posts

Re: Re: Databinding with PasswordBox

mchlsync,

Is the recipe to get password binding to work a secret ?

Why didnt you post the solution here ?

I would be interested in hearing how it's done ! Thank you !

moriravi
moriravi

Member

Member

2 points

1 Posts

Re: Re: Databinding with PasswordBox

Hi...... Checkout on this:

http://www.wpftutorial.net/DataBindPasswordProperty.html

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities