本文整理汇总了C#中System.Windows.Controls.PasswordBox类的典型用法代码示例。如果您正苦于以下问题:C# PasswordBox类的具体用法?C# PasswordBox怎么用?C# PasswordBox使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PasswordBox类属于System.Windows.Controls命名空间,在下文中一共展示了PasswordBox类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: switch
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) {
switch (connectionId)
{
case 1:
this.PassWord = ((System.Windows.Controls.PasswordBox)(target));
return;
case 2:
#line 12 "..\..\..\Password.xaml"
((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.Button_Click);
#line default
#line hidden
return;
case 3:
#line 13 "..\..\..\Password.xaml"
((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.Button_Click_1);
#line default
#line hidden
return;
}
this._contentLoaded = true;
}
示例2: AddPasswordBox
private static void AddPasswordBox(
UIElementCollection labelCollection, UIElementCollection inputCollection,
UIElementCollection checkBoxCollection,
string content, object dataContext, string key, int index)
{
var viewModel = (INotifyPropertyChanged)dataContext;
labelCollection.Add(new Label() { Content = content });
var control = new PasswordBox() { DataContext = dataContext, TabIndex = index };
var parameters = (IDictionary<string, string>)((dynamic)dataContext).Dictionary;
control.Password = parameters[key];
PropertyChangedEventHandler onSourceChanged = (sender, e) =>
{
if (e.PropertyName != key)
{
return;
}
if (control.Password == parameters[key])
{
return;
}
control.Password = parameters[key];
};
viewModel.PropertyChanged += onSourceChanged;
control.PasswordChanged += (sender, e) =>
{
if (parameters[key] != control.Password)
{
parameters[key] = control.Password;
}
};
control.Unloaded += (sender, e) => viewModel.PropertyChanged -= onSourceChanged;
inputCollection.Add(new UserControl() { Content = control });
checkBoxCollection.Add(new FrameworkElement());
}
示例3: SetEnabledForPasswordBox
private static void SetEnabledForPasswordBox(PasswordBox passwordBox, bool enabled)
{
if (enabled)
passwordBox.PasswordChanged += OnPasswordChanged;
else
passwordBox.PasswordChanged -= OnPasswordChanged;
}
示例4: SetPasswordBoxSelection
private static void SetPasswordBoxSelection(PasswordBox passwordBox, int start, int length)
{
var select = passwordBox.GetType().GetMethod("Select",
BindingFlags.Instance | BindingFlags.NonPublic);
select.Invoke(passwordBox, new object[] { start, length });
}
示例5: MessageBoxEvent
static void MessageBoxEvent(PasswordBox password)
{
password.PasswordChanged += delegate
{
MessageBox.Show("");
};
}
示例6: RegisterForm_AutoGeneratingField
/// <summary>
/// Wire up the Password and PasswordConfirmation accessors as the fields get generated.
/// Also bind the Question field to a ComboBox full of security questions, and handle the LostFocus event for the UserName TextBox.
/// </summary>
private void RegisterForm_AutoGeneratingField(object dataForm, DataFormAutoGeneratingFieldEventArgs e)
{
// Put all the fields in adding mode
e.Field.Mode = DataFieldMode.AddNew;
if (e.PropertyName == "UserName")
{
this.userNameTextBox = (TextBox)e.Field.Content;
this.userNameTextBox.LostFocus += this.UserNameLostFocus;
}
else if (e.PropertyName == "Password")
{
PasswordBox passwordBox = new PasswordBox();
e.Field.ReplaceTextBox(passwordBox, PasswordBox.PasswordProperty);
this.registrationData.PasswordAccessor = () => passwordBox.Password;
}
else if (e.PropertyName == "PasswordConfirmation")
{
PasswordBox passwordConfirmationBox = new PasswordBox();
e.Field.ReplaceTextBox(passwordConfirmationBox, PasswordBox.PasswordProperty);
this.registrationData.PasswordConfirmationAccessor = () => passwordConfirmationBox.Password;
}
else if (e.PropertyName == "Question")
{
ComboBox questionComboBox = new ComboBox();
questionComboBox.ItemsSource = RegistrationForm.GetSecurityQuestions();
e.Field.ReplaceTextBox(questionComboBox, ComboBox.SelectedItemProperty, binding => binding.Converter = new TargetNullValueConverter());
}
}
示例7: initTextinput
public void initTextinput(int maxLen, int inputMode)
{
if (m_inputFlag == 0)
{
// kEditBoxInputFlagPassword
PasswordBox pwdBox = new PasswordBox();
pwdBox.MaxLength = maxLen < 0 ? 0 : maxLen;
pwdBox.Password = m_strText;
pwdBox.GotFocus += pwdBox_GotFocus;
m_textinput = pwdBox;
}
else
{
TextBox textbox = new TextBox();
textbox.MaxLength = maxLen < 0 ? 0 : maxLen;
SetInputScope(textbox, inputMode);
textbox.TextChanged += textinput_TextChanged;
textbox.GotFocus += textinput_GotFocus;
textbox.LostFocus += textinput_LostFocus;
m_textinput = textbox;
}
m_textinput.Margin = new System.Windows.Thickness(0, 0, 220, 0);
m_textinput.Height = 72.0;
m_textinput.TabIndex = 0;
m_textinput.VerticalAlignment = VerticalAlignment.Top;
m_textinput.KeyDown += OnKeyDownHandler;
this.LayoutRoot.Children.Add(m_textinput);
}
示例8: OnApplyTemplate
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
PasswordBox = (PasswordBox)GetTemplateChild("PART_PasswordBox");
PasswordBox.PasswordChanged += PasswordBox_PasswordChanged;
}
示例9: CreateControl
public override FrameworkElement CreateControl(FormItemContext context)
{
PasswordBox tb = new PasswordBox();
CustomValidation.SetValidationCallback(tb, () =>
{
string errMsg = null;
if (tb.Password == null ||
tb.Password.Length < 6)
{
errMsg = "密码强度不够";
}
CustomValidation.SetValidationError(tb, errMsg);
return errMsg;
});
tb.PasswordChanged += (s, e) =>
{
CustomValidation.ForceValidation(tb);
context.SetValueToBindedProperty(tb.Password);
};
StyleHelper.ApplyStyle(tb, "editctl_pwd");
return tb;
}
示例10: BindablePasswordBox
public BindablePasswordBox() {
savedCallback = HandlePasswordChanged;
var passwordBox = new PasswordBox();
passwordBox.PasswordChanged += savedCallback;
Child = passwordBox;
}
示例11: GetHash
private static byte[] GetHash(PasswordBox pwb)
{
MD5 md5 = System.Security.Cryptography.MD5.Create();
byte[] inputBytes = System.Text.Encoding.ASCII.GetBytes(pwb.Password.ToString());
byte[] hash = md5.ComputeHash(inputBytes);
return hash;
}
示例12: MainCasePasswordBoxTest
public void MainCasePasswordBoxTest() {
var propertyChangedViewModel = new PropertyChangedViewModel();
var passwordBox = new PasswordBox() { DataContext = propertyChangedViewModel };
ShowWindow(passwordBox);
var behavior = new DependencyPropertyBehavior();
behavior.EventName = "PasswordChanged";
behavior.PropertyName = "Password";
Interaction.GetBehaviors(passwordBox).Add(behavior);
BindingOperations.SetBinding(behavior, DependencyPropertyBehavior.BindingProperty, new Binding("Text") { Mode = BindingMode.TwoWay });
Assert.AreEqual(0, propertyChangedViewModel.TextChangedCounter);
EnqueueShowWindow();
EnqueueCallback(() => {
passwordBox.Password = "123456";
});
EnqueueWindowUpdateLayout();
EnqueueCallback(() => {
Assert.AreEqual(1, propertyChangedViewModel.TextChangedCounter);
Assert.AreEqual("123456", propertyChangedViewModel.Text);
passwordBox.Password = "";
});
EnqueueWindowUpdateLayout();
EnqueueCallback(() => {
Assert.AreEqual(2, propertyChangedViewModel.TextChangedCounter);
propertyChangedViewModel.Text = "654321";
});
EnqueueWindowUpdateLayout();
EnqueueCallback(() => {
Assert.AreEqual("654321", passwordBox.Password);
});
EnqueueTestComplete();
}
示例13: PasswordBoxEx
/// <summary>
/// Saves the password changed callback and sets the child element to the password box.
/// </summary>
public PasswordBoxEx()
{
savedCallback = HandlePasswordChanged;
PasswordBox passwordBox = new PasswordBox();
passwordBox.PasswordChanged += savedCallback;
Child = passwordBox;
}
示例14: BindablePasswordBox
/// <summary>
/// Saves the password changed callback and sets the child element to the password box.
/// </summary>
public BindablePasswordBox()
{
_savedCallback = HandlePasswordChanged;
var passwordBox = new PasswordBox();
passwordBox.Style = Application.Current.Resources["CommonPasswordBoxStyle"] as Style;
passwordBox.PasswordChanged += _savedCallback;
Child = passwordBox;
}
示例15: PasswordBoxControl
public PasswordBoxControl()
{
savedCallback = HandlePasswordChanged;
var passwordBox = new PasswordBox();
passwordBox.ContextMenu = null;
passwordBox.PasswordChanged += savedCallback;
Child = passwordBox;
}