|
|
@@ -14,6 +14,9 @@ namespace Avalonia.Controls.Presenters
|
|
|
o => o.CaretIndex,
|
|
|
(o, v) => o.CaretIndex = v);
|
|
|
|
|
|
+ public static readonly StyledProperty<bool> ShowPasswordCharProperty =
|
|
|
+ AvaloniaProperty.Register<TextPresenter, bool>(nameof(ShowPasswordChar), true);
|
|
|
+
|
|
|
public static readonly StyledProperty<char> PasswordCharProperty =
|
|
|
AvaloniaProperty.Register<TextPresenter, char>(nameof(PasswordChar));
|
|
|
|
|
|
@@ -75,7 +78,7 @@ namespace Avalonia.Controls.Presenters
|
|
|
static TextPresenter()
|
|
|
{
|
|
|
AffectsRender<TextPresenter>(SelectionBrushProperty);
|
|
|
- AffectsMeasure<TextPresenter>(TextProperty, PasswordCharProperty,
|
|
|
+ AffectsMeasure<TextPresenter>(TextProperty, PasswordCharProperty, ShowPasswordCharProperty,
|
|
|
TextAlignmentProperty, TextWrappingProperty, TextBlock.FontSizeProperty,
|
|
|
TextBlock.FontStyleProperty, TextBlock.FontWeightProperty, TextBlock.FontFamilyProperty);
|
|
|
|
|
|
@@ -84,7 +87,7 @@ namespace Avalonia.Controls.Presenters
|
|
|
TextBlock.FontSizeProperty.Changed, TextBlock.FontStyleProperty.Changed,
|
|
|
TextBlock.FontWeightProperty.Changed, TextBlock.FontFamilyProperty.Changed,
|
|
|
SelectionStartProperty.Changed, SelectionEndProperty.Changed,
|
|
|
- SelectionForegroundBrushProperty.Changed, PasswordCharProperty.Changed
|
|
|
+ SelectionForegroundBrushProperty.Changed, PasswordCharProperty.Changed, ShowPasswordCharProperty.Changed
|
|
|
).AddClassHandler<TextPresenter>((x, _) => x.InvalidateFormattedText());
|
|
|
|
|
|
CaretIndexProperty.Changed.AddClassHandler<TextPresenter>((x, e) => x.CaretIndexChanged((int)e.NewValue));
|
|
|
@@ -210,6 +213,12 @@ namespace Avalonia.Controls.Presenters
|
|
|
set => SetValue(PasswordCharProperty, value);
|
|
|
}
|
|
|
|
|
|
+ public bool ShowPasswordChar
|
|
|
+ {
|
|
|
+ get => GetValue(ShowPasswordCharProperty);
|
|
|
+ set => SetValue(ShowPasswordCharProperty, value);
|
|
|
+ }
|
|
|
+
|
|
|
public IBrush SelectionBrush
|
|
|
{
|
|
|
get => GetValue(SelectionBrushProperty);
|
|
|
@@ -426,7 +435,7 @@ namespace Avalonia.Controls.Presenters
|
|
|
|
|
|
var text = Text;
|
|
|
|
|
|
- if (PasswordChar != default(char))
|
|
|
+ if (PasswordChar != default(char) && ShowPasswordChar)
|
|
|
{
|
|
|
result = CreateFormattedTextInternal(_constraint, new string(PasswordChar, text?.Length ?? 0));
|
|
|
}
|