diff --git a/src/Resolved.It.Maui.Controls/EnhancedEntry/EnhancedEntry.android.cs b/src/Resolved.It.Maui.Controls/EnhancedEntry/EnhancedEntry.android.cs index c334f34..2f5f7be 100644 --- a/src/Resolved.It.Maui.Controls/EnhancedEntry/EnhancedEntry.android.cs +++ b/src/Resolved.It.Maui.Controls/EnhancedEntry/EnhancedEntry.android.cs @@ -21,5 +21,13 @@ private static void AddEvents(IElementHandler? handler) private static void RemoveEvents(IElementHandler? handler) { + } + + private static void FillWidth(IElementHandler? handler) + { + } + + private static void OpenDropdown(IElementHandler? handler) + { } } \ No newline at end of file diff --git a/src/Resolved.It.Maui.Controls/EnhancedEntry/EnhancedEntry.macios.cs b/src/Resolved.It.Maui.Controls/EnhancedEntry/EnhancedEntry.macios.cs index 318dfb7..9466048 100644 --- a/src/Resolved.It.Maui.Controls/EnhancedEntry/EnhancedEntry.macios.cs +++ b/src/Resolved.It.Maui.Controls/EnhancedEntry/EnhancedEntry.macios.cs @@ -20,4 +20,12 @@ private static void AddEvents(IElementHandler? handler) private static void RemoveEvents(IElementHandler? handler) { } + + private static void FillWidth(IElementHandler? handler) + { + } + + private static void OpenDropdown(IElementHandler? handler) + { + } } \ No newline at end of file diff --git a/src/Resolved.It.Maui.Controls/EnhancedEntry/EnhancedEntry.shared.cs b/src/Resolved.It.Maui.Controls/EnhancedEntry/EnhancedEntry.shared.cs index 6a717a3..73d528f 100644 --- a/src/Resolved.It.Maui.Controls/EnhancedEntry/EnhancedEntry.shared.cs +++ b/src/Resolved.It.Maui.Controls/EnhancedEntry/EnhancedEntry.shared.cs @@ -281,13 +281,17 @@ private void SetupView() _entryFrame.Content = _entryFrameContent; + var placeholderTapGesture = new TapGestureRecognizer(); + placeholderTapGesture.Tapped += PlaceholderTapGestureOnTapped; + _placeholderLabel.GestureRecognizers.Add(placeholderTapGesture); + _placeholderLabel.SetBinding(Label.TextProperty, new Binding(nameof(Placeholder), source: this)); Children.Add(_entryFrame); Children.Add(_placeholderLabel); Children.Add(_errorLabel); } - + private static void ValidatableObjectChanged(BindableObject bindable, object oldValue, object newValue) { if (bindable is not EnhancedEntry enhancedEntry) @@ -425,12 +429,20 @@ private static void NewViewOnHandlerChanged(object? sender, EventArgs e) // https://learn.microsoft.com/en-us/dotnet/maui/user-interface/handlers/customize?view=net-maui-7.0#conditional-compilation AddEvents(view.Handler); RemoveBorder(view.Handler); + FillWidth(view.Handler); + } + + private void PlaceholderTapGestureOnTapped(object? sender, TappedEventArgs e) + { + _mainEntryControl?.Focus(); + OpenDropdown(_mainEntryControl?.Handler); + UpdateControlsState(true); } private void UpdateControlsState(bool isFocused) { var hasValue = !string.IsNullOrWhiteSpace(ValidatableObject?.StringValue); - + if (HasError) { _placeholderLabel.TextColor = PlaceholderErrorColor; diff --git a/src/Resolved.It.Maui.Controls/EnhancedEntry/EnhancedEntry.windows.cs b/src/Resolved.It.Maui.Controls/EnhancedEntry/EnhancedEntry.windows.cs index c33129c..8e8ca89 100644 --- a/src/Resolved.It.Maui.Controls/EnhancedEntry/EnhancedEntry.windows.cs +++ b/src/Resolved.It.Maui.Controls/EnhancedEntry/EnhancedEntry.windows.cs @@ -4,6 +4,7 @@ using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Input; using Microsoft.UI.Xaml.Media; +using HorizontalAlignment = Microsoft.UI.Xaml.HorizontalAlignment; // ReSharper disable once CheckNamespace namespace Resolved.It.Maui.Controls; @@ -54,4 +55,20 @@ private static void TextBox_GettingFocus(UIElement sender, GettingFocusEventArgs textBox.Resources["TextControlBorderThemeThicknessFocused"] = textBox.BorderThickness; textBox.Resources["TextControlBorderThemeThickness"] = textBox.BorderThickness; } + + private static void FillWidth(IElementHandler? handler) + { + if (handler?.PlatformView is not Microsoft.UI.Xaml.Controls.ComboBox comboBox) + return; + + comboBox.HorizontalAlignment = HorizontalAlignment.Stretch; + } + + private static void OpenDropdown(IElementHandler? handler) + { + if (handler?.PlatformView is not Microsoft.UI.Xaml.Controls.ComboBox comboBox) + return; + + comboBox.IsDropDownOpen = true; + } } \ No newline at end of file