Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class TextToPasswordCharConverter : IValueConverter
- {
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
- {
- var str = new string('*', value?.ToString().Length ?? 0);
- return str;
- }
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
- {
- //throw new NotImplementedException();
- return new object();
- }
- }
- public string PasswordField
- {
- get => passwordValue;
- set
- {
- passwordValue = value;
- OnPropertyChanged();
- }
- }
- public abstract class NotificationObject : INotifyPropertyChanged
- {
- public event PropertyChangedEventHandler PropertyChanged;
- protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
- {
- PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
- }
- protected void SetField<T>(ref T field, T value, [CallerMemberName] string propertyName = null)
- {
- if (!EqualityComparer<T>.Default.Equals(field, value))
- {
- field = value;
- OnPropertyChanged(propertyName);
- }
- }
- }
- <TextBox Grid.Row="0" Grid.Column="0" TextWrapping="Wrap" Margin="140,174,30,10">
- <TextBox.Text>
- <Binding Path="PasswordField" ValidatesOnDataErrors="True" Converter="{StaticResource TextToPasswordCharConverter}" UpdateSourceTrigger="PropertyChanged">
- <Binding.ValidationRules>
- <ExceptionValidationRule />
- </Binding.ValidationRules>
- </Binding>
- </TextBox.Text>
- </TextBox>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement