Password box not attaching to string Password property

Dec 12, 2011 at 12:18 PM


Im creating a login form for my wpf applicaiton... I've defined a


 <PasswordBox x:Name="Password" Grid.Row="2" Grid.Column="1"></PasswordBox>

but it wont' attach to the string Password defined in the viewmodel...


what am I missing?



Dec 12, 2011 at 1:55 PM

It appears, that the PasswordBox in WPF is lacking the dependency property for the password value. In other words, in WPF the PasswordBox doesn't have a bindable property for the password. In Silverlight it does and the above convention binding works just fine. In WPF it looks like you have to process the PasswordChanged event.

        <PasswordBox Name="Password"   
                     cal:Message.Attach="[Event PasswordChanged] = [Action PasswordChanged($source)]"
    public class MainViewModel : Screen
        private string _password;
        public string Password
            get { return _password; }
                _password = value;
                NotifyOfPropertyChange(() => Password);
        public void ShowPassword()
        public void PasswordChanged(PasswordBox source)
            Password = source.Password;