diff --git a/samples/ControlCatalog/Pages/TextBoxPage.xaml b/samples/ControlCatalog/Pages/TextBoxPage.xaml
index 058bcff84de..425a1b376a0 100644
--- a/samples/ControlCatalog/Pages/TextBoxPage.xaml
+++ b/samples/ControlCatalog/Pages/TextBoxPage.xaml
@@ -38,6 +38,7 @@
UseFloatingWatermark="True"
PasswordChar="*"
Text="Password" />
+
diff --git a/src/Android/Avalonia.Android/Platform/Input/AndroidInputMethod.cs b/src/Android/Avalonia.Android/Platform/Input/AndroidInputMethod.cs
index cb105197cbc..fec48a1c9c1 100644
--- a/src/Android/Avalonia.Android/Platform/Input/AndroidInputMethod.cs
+++ b/src/Android/Avalonia.Android/Platform/Input/AndroidInputMethod.cs
@@ -172,6 +172,9 @@ public void SetOptions(TextInputOptions options)
if (options.Multiline)
outAttrs.InputType |= InputTypes.TextFlagMultiLine;
+ if (outAttrs.InputType is InputTypes.ClassText && options.HideSuggestions)
+ outAttrs.InputType |= InputTypes.TextVariationPassword | InputTypes.TextFlagNoSuggestions;
+
outAttrs.ImeOptions = options.ReturnKeyType switch
{
TextInputReturnKeyType.Return => ImeFlags.NoEnterAction,
diff --git a/src/Avalonia.Base/Input/TextInput/TextInputOptions.cs b/src/Avalonia.Base/Input/TextInput/TextInputOptions.cs
index c33f5641a85..65662b0f7c4 100644
--- a/src/Avalonia.Base/Input/TextInput/TextInputOptions.cs
+++ b/src/Avalonia.Base/Input/TextInput/TextInputOptions.cs
@@ -253,4 +253,37 @@ public static bool GetIsSensitive(StyledElement avaloniaObject)
/// Text contains sensitive data like card numbers and should not be stored
///
public bool IsSensitive { get; set; }
+
+ ///
+ /// Defines the property.
+ ///
+ public static readonly AttachedProperty HideSuggestionsProperty =
+ AvaloniaProperty.RegisterAttached(
+ "HideSuggestions",
+ inherits: true);
+
+ ///
+ /// Sets the value of the attached on a control.
+ ///
+ /// The control.
+ /// The property value to set.
+ public static void SetHideSuggestions(StyledElement avaloniaObject, bool value)
+ {
+ avaloniaObject.SetValue(HideSuggestionsProperty, value);
+ }
+
+ ///
+ /// Gets the value of the attached .
+ ///
+ /// The target.
+ /// true if HideSuggestions
+ public static bool GetHideSuggestions(StyledElement avaloniaObject)
+ {
+ return avaloniaObject.GetValue(HideSuggestionsProperty);
+ }
+
+ ///
+ /// Hide virtual keyboard suggestions
+ ///
+ public bool HideSuggestions { get; set; }
}
diff --git a/src/iOS/Avalonia.iOS/TextInputResponder.Properties.cs b/src/iOS/Avalonia.iOS/TextInputResponder.Properties.cs
index ab0d92e5fae..219e2847581 100644
--- a/src/iOS/Avalonia.iOS/TextInputResponder.Properties.cs
+++ b/src/iOS/Avalonia.iOS/TextInputResponder.Properties.cs
@@ -12,7 +12,12 @@ partial class TextInputResponder
public UITextAutocapitalizationType AutocapitalizationType { get; private set; }
[Export("autocorrectionType")]
- public UITextAutocorrectionType AutocorrectionType => UITextAutocorrectionType.Yes;
+ public UITextAutocorrectionType AutocorrectionType =>
+ _view._options == null ?
+ UITextAutocorrectionType.Yes :
+ _view._options.HideSuggestions ?
+ UITextAutocorrectionType.No :
+ UITextAutocorrectionType.Yes;
[Export("keyboardType")]
public UIKeyboardType KeyboardType =>
@@ -64,7 +69,13 @@ public UIReturnKeyType ReturnKeyType
_view._options?.ContentType is TextInputContentType.Password or TextInputContentType.Pin
|| (_view._options?.IsSensitive ?? false);
- [Export("spellCheckingType")] public UITextSpellCheckingType SpellCheckingType => UITextSpellCheckingType.Yes;
+ [Export("spellCheckingType")]
+ public UITextSpellCheckingType SpellCheckingType =>
+ _view._options == null ?
+ UITextSpellCheckingType.Yes :
+ _view._options.HideSuggestions ?
+ UITextSpellCheckingType.No :
+ UITextSpellCheckingType.Yes;
[Export("textContentType")] public NSString TextContentType { get; set; } = new NSString("text/plain");