public void TestMethod1() { var behavior = new UpdatePasswordBindingOnPropertyChanged(); var bindingSource = new BindingSource { Value = "InitialValue" }; var binding = new Binding("Value") { Source = bindingSource, Mode = BindingMode.TwoWay, UpdateSourceTrigger = UpdateSourceTrigger.Explicit }; var passwordBox = new PasswordBox(); base.TestPanel.Children.Add(passwordBox); EnqueueCallback(() => { passwordBox.SetBinding(PasswordBox.PasswordProperty, binding); Interaction.GetBehaviors(passwordBox).Add(behavior); passwordBox.Password = "******"; }); EnqueueCallback(() => Assert.AreEqual("NewValue", bindingSource.Value)); this.EnqueueTestComplete(); }
/// <summary> /// Creates the password control. /// </summary> /// <param name="property">The property.</param> /// <returns> /// The control. /// </returns> protected virtual FrameworkElement CreatePasswordControl(PropertyItem property) { var c = new PasswordBox(); PasswordHelper.SetAttach(c, true); c.SetBinding(PasswordHelper.PasswordProperty, property.CreateBinding()); return c; }