本文整理汇总了C#中System.Windows.Controls.PasswordBox.SetBinding方法的典型用法代码示例。如果您正苦于以下问题:C# PasswordBox.SetBinding方法的具体用法?C# PasswordBox.SetBinding怎么用?C# PasswordBox.SetBinding使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Controls.PasswordBox
的用法示例。
在下文中一共展示了PasswordBox.SetBinding方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestMethod1
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 = "NewValue";
});
EnqueueCallback(() => Assert.AreEqual("NewValue", bindingSource.Value));
this.EnqueueTestComplete();
}
示例2: CreatePasswordControl
/// <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;
}