diff --git a/samples/ControlCatalog/Pages/TextBoxPage.xaml b/samples/ControlCatalog/Pages/TextBoxPage.xaml
index 87fb1f0b4e..96b534fc58 100644
--- a/samples/ControlCatalog/Pages/TextBoxPage.xaml
+++ b/samples/ControlCatalog/Pages/TextBoxPage.xaml
@@ -15,9 +15,10 @@
UseFloatingWatermark="True"
Text="Lorem ipsum dolor sit amet, consectetur adipiscing elit."/>
-
diff --git a/src/Avalonia.Controls/PasswordBox.cs b/src/Avalonia.Controls/PasswordBox.cs
deleted file mode 100644
index a7dd03445a..0000000000
--- a/src/Avalonia.Controls/PasswordBox.cs
+++ /dev/null
@@ -1,47 +0,0 @@
-using Avalonia.Controls.Primitives;
-using Avalonia.Styling;
-using System;
-
-namespace Avalonia.Controls
-{
- public class PasswordBox : TextBox, IStyleable
- {
- Type IStyleable.StyleKey => typeof(PasswordBox);
-
- public PasswordBox()
- {
- this.GetObservable(TextProperty).Subscribe(text =>
- {
- if (text != null)
- {
- DisplayText = new string(PasswordChar, text.Length);
- }
- else
- {
- DisplayText = null;
- }
- });
- }
-
- public static readonly StyledProperty PasswordCharProperty = AvaloniaProperty.Register(nameof(PasswordChar), '*');
-
- public char PasswordChar
- {
- get => GetValue(PasswordCharProperty);
- set => SetValue(PasswordCharProperty, value);
- }
-
- public static readonly StyledProperty DisplayTextProperty = AvaloniaProperty.Register(nameof(DisplayText));
-
- public string DisplayText
- {
- get => GetValue(DisplayTextProperty);
- set => SetValue(DisplayTextProperty, value);
- }
-
- protected override void OnTemplateApplied(TemplateAppliedEventArgs e)
- {
- base.OnTemplateApplied(e);
- }
- }
-}
diff --git a/src/Avalonia.Controls/TextBox.cs b/src/Avalonia.Controls/TextBox.cs
index 890926db54..a0096ef7ae 100644
--- a/src/Avalonia.Controls/TextBox.cs
+++ b/src/Avalonia.Controls/TextBox.cs
@@ -30,7 +30,10 @@ namespace Avalonia.Controls
nameof(CaretIndex),
o => o.CaretIndex,
(o, v) => o.CaretIndex = v);
-
+
+ public static readonly StyledProperty PasswordCharProperty =
+ AvaloniaProperty.Register(nameof(PasswordChar));
+
public static readonly StyledProperty IsReadOnlyProperty =
AvaloniaProperty.Register(nameof(IsReadOnly));
@@ -53,6 +56,9 @@ namespace Avalonia.Controls
defaultBindingMode: BindingMode.TwoWay,
enableDataValidation: true);
+ public static readonly StyledProperty DisplayTextProperty =
+ AvaloniaProperty.Register(nameof(DisplayText));
+
public static readonly StyledProperty TextAlignmentProperty =
TextBlock.TextAlignmentProperty.AddOwner();
@@ -78,7 +84,7 @@ namespace Avalonia.Controls
public bool Equals(UndoRedoState other) => ReferenceEquals(Text, other.Text) || Equals(Text, other.Text);
}
-
+
private string _text;
private int _caretIndex;
private int _selectionStart;
@@ -117,6 +123,18 @@ namespace Avalonia.Controls
horizontalScrollBarVisibility,
BindingPriority.Style);
_undoRedoHelper = new UndoRedoHelper(this);
+
+ this.GetObservable(TextProperty).Subscribe(text =>
+ {
+ if (PasswordChar != default(char))
+ {
+ DisplayText = new string(PasswordChar, text.Length);
+ }
+ else
+ {
+ DisplayText = Text;
+ }
+ });
}
public bool AcceptsReturn
@@ -147,7 +165,13 @@ namespace Avalonia.Controls
_undoRedoHelper.UpdateLastState();
}
}
-
+
+ public char PasswordChar
+ {
+ get => GetValue(PasswordCharProperty);
+ set => SetValue(PasswordCharProperty, value);
+ }
+
public bool IsReadOnly
{
get { return GetValue(IsReadOnlyProperty); }
@@ -208,6 +232,12 @@ namespace Avalonia.Controls
}
}
+ public string DisplayText
+ {
+ get => GetValue(DisplayTextProperty);
+ set => SetValue(DisplayTextProperty, value);
+ }
+
public TextAlignment TextAlignment
{
get { return GetValue(TextAlignmentProperty); }
@@ -832,9 +862,9 @@ namespace Avalonia.Controls
private void SetTextInternal(string value)
{
try
- {
+ {
_ignoreTextChanges = true;
- SetAndRaise(TextProperty, ref _text, value);
+ SetAndRaise(TextProperty, ref _text, value);
}
finally
{
diff --git a/src/Avalonia.Themes.Default/PasswordBox.xaml b/src/Avalonia.Themes.Default/PasswordBox.xaml
deleted file mode 100644
index 4297a69bab..0000000000
--- a/src/Avalonia.Themes.Default/PasswordBox.xaml
+++ /dev/null
@@ -1,64 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/Avalonia.Themes.Default/TextBox.xaml b/src/Avalonia.Themes.Default/TextBox.xaml
index e228aebf58..52e98b0c57 100644
--- a/src/Avalonia.Themes.Default/TextBox.xaml
+++ b/src/Avalonia.Themes.Default/TextBox.xaml
@@ -38,12 +38,12 @@
Text="{TemplateBinding Watermark}"
IsVisible="{TemplateBinding Path=Text, Converter={x:Static StringConverters.NullOrEmpty}}"/>
+ TextWrapping="{TemplateBinding TextWrapping}"/>