Note that there are some explanatory texts on larger screens.

plurals
  1. POget checked event data binding wpf
    text
    copied!<p>I created a textbox ,a passwordbox and a toggle button in wpf. I need,when I checked the button,the password to be visible, and when the button is unchecked the characters are shown as bullets. My problem is , when I run the application, the button is unchecked (this means hidden password) ,but the password is still shown. Just after I checked the button,everything works as I want. How can I make to binding from start? Not only after I checked it</p> <p>XML code:</p> <pre><code> &lt;ToggleButton Name="toggle1" Height="40" Padding="0" Width="56" Canvas.Left="131" Canvas.Top="0" BorderBrush="{x:Null}" IsChecked="{Binding ShowPassword}"&gt; </code></pre> <p>code:</p> <pre><code>public bool IsPasswordVisible { get { return _IsPasswordVisible; } set { if (_IsPasswordVisible == value) return; _IsPasswordVisible = value; if(IsPasswordVisible) { passwordBox1.Visibility = System.Windows.Visibility.Collapsed; textbox1.Visibility = System.Windows.Visibility.Visible; textbox1.EditValue = passwordBoxEdit1.Password; }else{ passwordBox1.Visibility = System.Windows.Visibility.Visible; textbox1.Visibility = System.Windows.Visibility.Collapsed; passwordBox1.Password = textEdit1.Text; } if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("ShowPassword")); } } public MainWindow() { InitializeComponent(); this.DataContext = this; } public event PropertyChangedEventHandler PropertyChanged; #region OnPropertyChanged /// &lt;summary&gt; /// Triggers the PropertyChanged event. /// &lt;/summary&gt; protected void OnPropertyChanged(string propertyName) { PropertyChangedEventHandler handler = PropertyChanged; if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName)); } #endregion </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload