Kaynağa Gözat

Fixes #1847 PasswordChar change doesn't affect render

Miha Markič 7 yıl önce
ebeveyn
işleme
298eef1c1b

+ 9 - 2
src/Avalonia.Controls/Presenters/TextPresenter.cs

@@ -36,7 +36,11 @@ namespace Avalonia.Controls.Presenters
         private int _selectionEnd;
         private int _selectionEnd;
         private bool _caretBlink;
         private bool _caretBlink;
         private IBrush _highlightBrush;
         private IBrush _highlightBrush;
-
+        
+        static TextPresenter()
+        {
+            AffectsRender(PasswordCharProperty);
+        }
         public TextPresenter()
         public TextPresenter()
         {
         {
             _caretTimer = new DispatcherTimer();
             _caretTimer = new DispatcherTimer();
@@ -50,6 +54,9 @@ namespace Avalonia.Controls.Presenters
 
 
             this.GetObservable(CaretIndexProperty)
             this.GetObservable(CaretIndexProperty)
                 .Subscribe(CaretIndexChanged);
                 .Subscribe(CaretIndexChanged);
+
+            this.GetObservable(PasswordCharProperty)
+                .Subscribe(_ => InvalidateFormattedText());
         }
         }
 
 
         public int CaretIndex
         public int CaretIndex
@@ -116,7 +123,7 @@ namespace Avalonia.Controls.Presenters
                 var start = Math.Min(selectionStart, selectionEnd);
                 var start = Math.Min(selectionStart, selectionEnd);
                 var length = Math.Max(selectionStart, selectionEnd) - start;
                 var length = Math.Max(selectionStart, selectionEnd) - start;
 
 
-                // issue #600: set constaint before any FormattedText manipulation
+                // issue #600: set constraint before any FormattedText manipulation
                 //             see base.Render(...) implementation
                 //             see base.Render(...) implementation
                 FormattedText.Constraint = Bounds.Size;
                 FormattedText.Constraint = Bounds.Size;