
Private static bool GetIsUpdating(DependencyObject dp) Public static void SetPassword(DependencyObject dp, string value) Return (string)dp.GetValue(PasswordProperty) Public static string GetPassword(DependencyObject dp) Return (bool)dp.GetValue(AttachProperty) Public static bool GetAttach(DependencyObject dp) Public static void SetAttach(DependencyObject dp, bool value) Private static readonly DependencyProperty IsUpdatingProperty =ĭependencyProperty.RegisterAttached("IsUpdating", typeof(bool), Typeof(bool), typeof(PasswordHelper), new PropertyMetadata(false, Attach)) Public static readonly DependencyProperty AttachProperty =ĭependencyProperty.RegisterAttached("Attach", New FrameworkPropertyMetadata(string.Empty, OnPasswordPropert圜hanged)) Public static readonly DependencyProperty PasswordProperty =ĭependencyProperty.RegisterAttached("Password", There's an attached property based helper class here: The equivalent is Password, but I think you will find there's an issue in that it's not a dependency property.

There is no XAML only solution however if that's what you are looking for. Pb.Tag = (!string.IsNullOrEmpty(pb.Password)).ToString() private void OnPasswordChanged(object sender, RoutedEventArgs e)

Passwordbox password#
You could handle the PasswordChanged event of the PasswordBox and set its Tag property to "True" or "False" depending on whether the Password property contains any characters and then check the value of the Tag property in the trigger. Return ( bool) dp.There is a Password property but you won't be able to use it like the Text property since it is not a dependency property. Private static bool GetUpdatingPassword( DependencyObject dp) Public static void SetBoundPassword( DependencyObject dp, string value) Public static string GetBoundPassword( DependencyObject dp) Public static bool GetBindPassword( DependencyObject dp) Public static void SetBindPassword( DependencyObject dp, bool value) push the new password into the BoundPassword property SetBoundPassword( box, box. set a flag to indicate that we're updating the password SetUpdatingPassword( box, true) Private static void HandlePasswordChanged( object sender, RoutedEventArgs e) PasswordChanged -= HandlePasswordChanged when the BindPassword attached property is set on a PasswordBox, // start listening to its PasswordChanged event PasswordBox box = dp as PasswordBox īox. Private static void OnBindPasswordChanged( DependencyObject dp, DependencyPropert圜hangedEventArgs e) PasswordChanged += HandlePasswordChanged avoid recursive updating by ignoring the box's changed event box. only handle this event when the property is attached to a PasswordBox // and when the BindPassword attached property has been set to true if ( d = null || ! GetBindPassword( d)) Private static void OnBoundPasswordChanged( DependencyObject d, DependencyPropert圜hangedEventArgs e) RegisterAttached( "UpdatingPassword ", typeof( bool), typeof( PasswordBoxAssistant), new PropertyMetadata( false)) Private static readonly DependencyProperty UpdatingPassword = DependencyProperty. "BindPassword ", typeof( bool), typeof( PasswordBoxAssistant), new PropertyMetadata( false, OnBindPasswordChanged)) Public static readonly DependencyProperty BindPassword = DependencyProperty.

RegisterAttached( "BoundPassword ", typeof( string), typeof( PasswordBoxAssistant), new PropertyMetadata( string. Public static readonly DependencyProperty BoundPassword = DependencyProperty.
