From 1934d8c9e92d53362d26dab6ff9aabf46b2dae60 Mon Sep 17 00:00:00 2001 From: mhrastegari Date: Fri, 26 Dec 2025 16:59:57 +0330 Subject: [PATCH 01/11] add HasBorder proprty to Entry --- src/Controls/src/Core/Entry/Entry.cs | 15 +++++++++++++++ src/Core/src/Core/IEntry.cs | 5 +++++ .../src/Handlers/Entry/EntryHandler.Standard.cs | 1 + src/Core/src/Handlers/Entry/EntryHandler.cs | 1 + 4 files changed, 22 insertions(+) diff --git a/src/Controls/src/Core/Entry/Entry.cs b/src/Controls/src/Core/Entry/Entry.cs index 9681fd5b8ec7..6fa9911721c5 100644 --- a/src/Controls/src/Core/Entry/Entry.cs +++ b/src/Controls/src/Core/Entry/Entry.cs @@ -37,6 +37,11 @@ public partial class Entry : InputView, ITextAlignmentElement, IEntryController, /// public static readonly BindableProperty IsPasswordProperty = BindableProperty.Create(nameof(IsPassword), typeof(bool), typeof(Entry), default(bool)); + /// + /// Backing store for the property. + /// + public static readonly BindableProperty HasBorderProperty = BindableProperty.Create(nameof(HasBorder), typeof(bool), typeof(Entry), true); + /// public new static readonly BindableProperty TextProperty = InputView.TextProperty; @@ -125,6 +130,16 @@ public bool IsPassword set { SetValue(IsPasswordProperty, value); } } + /// + /// Gets or sets a value that indicating if the Entry has a border displayed. This is a bindable property. + /// + public bool HasBorder + { + get { return (bool)GetValue(HasBorderProperty); } + set { SetValue(HasBorderProperty, value); } + } + + /// /// Determines what the return key on the on-screen keyboard should look like. This is a bindable property. /// diff --git a/src/Core/src/Core/IEntry.cs b/src/Core/src/Core/IEntry.cs index f66cbaff5978..e4697b5a8076 100644 --- a/src/Core/src/Core/IEntry.cs +++ b/src/Core/src/Core/IEntry.cs @@ -10,6 +10,11 @@ public interface IEntry : IView, ITextInput, ITextAlignment /// bool IsPassword { get; } + /// + /// Gets a value that indicates if the Entry has a border displayed. + /// + bool HasBorder { get; } + /// /// Gets an enumeration value that controls the appearance of the return button. /// diff --git a/src/Core/src/Handlers/Entry/EntryHandler.Standard.cs b/src/Core/src/Handlers/Entry/EntryHandler.Standard.cs index adf3cb2ab6a4..b6a9b920cf57 100644 --- a/src/Core/src/Handlers/Entry/EntryHandler.Standard.cs +++ b/src/Core/src/Handlers/Entry/EntryHandler.Standard.cs @@ -9,6 +9,7 @@ public partial class EntryHandler : ViewHandler public static void MapText(IEntryHandler handler, IEntry entry) { } public static void MapTextColor(IEntryHandler handler, IEntry entry) { } public static void MapIsPassword(IEntryHandler handler, IEntry entry) { } + public static void MapHasBorder(IEntryHandler handler, IEntry entry) { } public static void MapHorizontalTextAlignment(IEntryHandler handler, IEntry entry) { } public static void MapVerticalTextAlignment(IEntryHandler handler, IEntry entry) { } diff --git a/src/Core/src/Handlers/Entry/EntryHandler.cs b/src/Core/src/Handlers/Entry/EntryHandler.cs index 3d4d666adffc..5552f156c738 100644 --- a/src/Core/src/Handlers/Entry/EntryHandler.cs +++ b/src/Core/src/Handlers/Entry/EntryHandler.cs @@ -24,6 +24,7 @@ public partial class EntryHandler : IEntryHandler [nameof(IEntry.ClearButtonVisibility)] = MapClearButtonVisibility, [nameof(IEntry.Font)] = MapFont, [nameof(IEntry.IsPassword)] = MapIsPassword, + [nameof(IEntry.HasBorder)] = MapHasBorder, [nameof(IEntry.HorizontalTextAlignment)] = MapHorizontalTextAlignment, [nameof(IEntry.VerticalTextAlignment)] = MapVerticalTextAlignment, [nameof(IEntry.IsReadOnly)] = MapIsReadOnly, From 4de500556615aa27f2ce2523ddb9555d77ad5ba7 Mon Sep 17 00:00:00 2001 From: mhrastegari Date: Fri, 26 Dec 2025 17:00:44 +0330 Subject: [PATCH 02/11] add Android implementation --- .../Handlers/Entry/EntryHandler.Android.cs | 7 ++++++ .../Platform/Android/EditTextExtensions.cs | 23 +++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/src/Core/src/Handlers/Entry/EntryHandler.Android.cs b/src/Core/src/Handlers/Entry/EntryHandler.Android.cs index 89cf47582001..38768f7c1a6d 100644 --- a/src/Core/src/Handlers/Entry/EntryHandler.Android.cs +++ b/src/Core/src/Handlers/Entry/EntryHandler.Android.cs @@ -90,6 +90,13 @@ public static void MapIsPassword(IEntryHandler handler, IEntry entry) handler.PlatformView?.UpdateIsPassword(entry); } + public static void MapHasBorder(IEntryHandler handler, IEntry entry) + { + handler.UpdateValue(nameof(IEntry.Text)); + + handler.PlatformView?.UpdateHasBorder(entry); + } + public static void MapHorizontalTextAlignment(IEntryHandler handler, IEntry entry) => handler.PlatformView?.UpdateHorizontalTextAlignment(entry); diff --git a/src/Core/src/Platform/Android/EditTextExtensions.cs b/src/Core/src/Platform/Android/EditTextExtensions.cs index bbb99c029ab4..079509860b35 100644 --- a/src/Core/src/Platform/Android/EditTextExtensions.cs +++ b/src/Core/src/Platform/Android/EditTextExtensions.cs @@ -73,6 +73,29 @@ public static void UpdateIsPassword(this EditText editText, IEntry entry) editText.SetInputType(entry); } + public static void UpdateHasBorder(this EditText editText, IEntry entry) + { + if (entry.HasBorder) + { + if (OperatingSystem.IsAndroidVersionAtLeast(23) && editText.Context?.Theme is Resources.Theme theme) + { + using var typedValue = new TypedValue(); + if (theme.ResolveAttribute(global::Android.Resource.Attribute.ColorAccent, typedValue, true)) + { + if (editText.Resources?.GetColorStateList(typedValue.ResourceId, theme) is ColorStateList accentColorStateList) + { + editText.BackgroundTintList = accentColorStateList; + return; + } + } + } + } + else + { + editText.BackgroundTintList = ColorStateList.ValueOf(Colors.Transparent.ToPlatform()); + } + } + public static void UpdateHorizontalTextAlignment(this EditText editText, ITextAlignment textAlignment) { editText.UpdateHorizontalAlignment(textAlignment.HorizontalTextAlignment); From 821fb4d92030fb8961c98459a731ed649741dd7c Mon Sep 17 00:00:00 2001 From: mhrastegari Date: Fri, 26 Dec 2025 17:01:17 +0330 Subject: [PATCH 03/11] add Windows implementation --- .../Handlers/Entry/EntryHandler.Windows.cs | 3 +++ .../src/Platform/Windows/TextBoxExtensions.cs | 21 +++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/src/Core/src/Handlers/Entry/EntryHandler.Windows.cs b/src/Core/src/Handlers/Entry/EntryHandler.Windows.cs index 6b7ec0c2d829..437bade72877 100644 --- a/src/Core/src/Handlers/Entry/EntryHandler.Windows.cs +++ b/src/Core/src/Handlers/Entry/EntryHandler.Windows.cs @@ -97,6 +97,9 @@ public static void MapClearButtonVisibility(IEntryHandler handler, IEntry entry) public static void MapCharacterSpacing(IEntryHandler handler, IEntry entry) => handler.PlatformView?.UpdateCharacterSpacing(entry); + public static void MapHasBorder(IEntryHandler handler, IEntry entry) => + handler.PlatformView?.UpdateHasBorder(entry); + public static void MapKeyboard(IEntryHandler handler, IEntry entry) => handler.PlatformView?.UpdateKeyboard(entry); diff --git a/src/Core/src/Platform/Windows/TextBoxExtensions.cs b/src/Core/src/Platform/Windows/TextBoxExtensions.cs index a1c8da2dad7e..2eb6c0907b76 100644 --- a/src/Core/src/Platform/Windows/TextBoxExtensions.cs +++ b/src/Core/src/Platform/Windows/TextBoxExtensions.cs @@ -50,6 +50,27 @@ public static void UpdateBackground(this TextBox textBox, IView view) "TextControlBackgroundDisabled", }; + public static void UpdateHasBorder(this TextBox textBox, IEntry entry) + { + if (entry.HasBorder) + { + textBox.Resources.RemoveKeys(BorderThicknessResourceKeys); + textBox.ClearValue(Control.BorderThicknessProperty); + } + else + { + textBox.Resources.SetValueForAllKey(BorderThicknessResourceKeys, WinUIHelpers.CreateThickness(0)); + } + + textBox.RefreshThemeResources(); + } + + static readonly string[] BorderThicknessResourceKeys = + { + "TextControlBorderThemeThickness", + "TextControlBorderThemeThicknessFocused" + }; + public static void UpdateTextColor(this TextBox textBox, ITextStyle textStyle) { var brush = textStyle.TextColor?.ToPlatform(); From 78cf18b7bf4554b7f87dd78e81e928d802e2211d Mon Sep 17 00:00:00 2001 From: mhrastegari Date: Fri, 26 Dec 2025 17:02:30 +0330 Subject: [PATCH 04/11] add MaciOS implementation --- src/Core/src/Handlers/Entry/EntryHandler.iOS.cs | 3 +++ src/Core/src/Platform/iOS/TextFieldExtensions.cs | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/Core/src/Handlers/Entry/EntryHandler.iOS.cs b/src/Core/src/Handlers/Entry/EntryHandler.iOS.cs index e6e2030716c8..75117d8b8351 100644 --- a/src/Core/src/Handlers/Entry/EntryHandler.iOS.cs +++ b/src/Core/src/Handlers/Entry/EntryHandler.iOS.cs @@ -105,6 +105,9 @@ public static void MapSelectionLength(IEntryHandler handler, IEntry entry) => public static void MapClearButtonVisibility(IEntryHandler handler, IEntry entry) => handler.PlatformView?.UpdateClearButtonVisibility(entry); + public static void MapHasBorder(IEntryHandler handler, IEntry entry) => + handler.PlatformView?.UpdateHasBorder(entry); + public static void MapFormatting(IEntryHandler handler, IEntry entry) { handler.PlatformView?.UpdateMaxLength(entry); diff --git a/src/Core/src/Platform/iOS/TextFieldExtensions.cs b/src/Core/src/Platform/iOS/TextFieldExtensions.cs index 7a501d0d8f83..cb173ca48701 100644 --- a/src/Core/src/Platform/iOS/TextFieldExtensions.cs +++ b/src/Core/src/Platform/iOS/TextFieldExtensions.cs @@ -196,6 +196,18 @@ static UITextPosition GetSelectionEnd(UITextField textField, IEntry entry, UITex return end; } + public static void UpdateHasBorder(this UITextField textField, IEntry entry) + { + if (entry.HasBorder) + { + textField.BorderStyle = UITextBorderStyle.RoundedRect; + } + else + { + textField.BorderStyle = UITextBorderStyle.None; + } + } + public static void UpdateClearButtonVisibility(this UITextField textField, IEntry entry) { if (entry.ClearButtonVisibility == ClearButtonVisibility.WhileEditing) From 172e3d1fd9776e29e82e4a9f8afc3e12c414ea70 Mon Sep 17 00:00:00 2001 From: mhrastegari Date: Fri, 26 Dec 2025 20:49:12 +0330 Subject: [PATCH 05/11] add sample --- .../Pages/Controls/EntryPage.xaml | 74 ++++++++++--------- 1 file changed, 40 insertions(+), 34 deletions(-) diff --git a/src/Controls/samples/Controls.Sample/Pages/Controls/EntryPage.xaml b/src/Controls/samples/Controls.Sample/Pages/Controls/EntryPage.xaml index 425a9d45de74..f880a7860a6d 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Controls/EntryPage.xaml +++ b/src/Controls/samples/Controls.Sample/Pages/Controls/EntryPage.xaml @@ -1,10 +1,10 @@  @@ -15,12 +15,12 @@ - + - + @@ -52,6 +52,12 @@ Style="{StaticResource Headline}" /> +