diff --git a/src/Compatibility/Core/src/WinUI/LabelRenderer.cs b/src/Compatibility/Core/src/WinUI/LabelRenderer.cs index b0956a16d0fa..08db57109a94 100644 --- a/src/Compatibility/Core/src/WinUI/LabelRenderer.cs +++ b/src/Compatibility/Core/src/WinUI/LabelRenderer.cs @@ -224,7 +224,7 @@ void UpdateTextDecorations(TextBlock textBlock) } - [PortHandler("Partially ported")] + [PortHandler] void UpdateAlign(TextBlock textBlock) { _perfectSizeValid = false; diff --git a/src/Core/src/Handlers/Label/LabelHandler.Android.cs b/src/Core/src/Handlers/Label/LabelHandler.Android.cs index e21fbdb997a0..0b52af96185a 100644 --- a/src/Core/src/Handlers/Label/LabelHandler.Android.cs +++ b/src/Core/src/Handlers/Label/LabelHandler.Android.cs @@ -53,6 +53,9 @@ public static void MapHorizontalTextAlignment(LabelHandler handler, ILabel label handler.NativeView?.UpdateHorizontalTextAlignment(label); } + [MissingMapper] + public static void MapVerticalTextAlignment(LabelHandler handler, ILabel label) { } + public static void MapLineBreakMode(LabelHandler handler, ILabel label) { handler.NativeView?.UpdateLineBreakMode(label); diff --git a/src/Core/src/Handlers/Label/LabelHandler.Standard.cs b/src/Core/src/Handlers/Label/LabelHandler.Standard.cs index a71c62e51d04..34a6ab490025 100644 --- a/src/Core/src/Handlers/Label/LabelHandler.Standard.cs +++ b/src/Core/src/Handlers/Label/LabelHandler.Standard.cs @@ -11,6 +11,7 @@ public static void MapTextColor(IViewHandler handler, ILabel label) { } public static void MapCharacterSpacing(IViewHandler handler, ILabel label) { } public static void MapFont(LabelHandler handler, ILabel label) { } public static void MapHorizontalTextAlignment(LabelHandler handler, ILabel label) { } + public static void MapVerticalTextAlignment(LabelHandler handler, ILabel label) { } public static void MapLineBreakMode(LabelHandler handler, ILabel label) { } public static void MapTextDecorations(LabelHandler handler, ILabel label) { } public static void MapMaxLines(IViewHandler handler, ILabel label) { } diff --git a/src/Core/src/Handlers/Label/LabelHandler.Windows.cs b/src/Core/src/Handlers/Label/LabelHandler.Windows.cs index 3e7f32ce29c9..7530d095feaf 100644 --- a/src/Core/src/Handlers/Label/LabelHandler.Windows.cs +++ b/src/Core/src/Handlers/Label/LabelHandler.Windows.cs @@ -34,10 +34,13 @@ public static void MapFont(LabelHandler handler, ILabel label) handler.NativeView?.UpdateFont(label, fontManager); } - public static void MapHorizontalTextAlignment(LabelHandler handler, ILabel label) => + public static void MapHorizontalTextAlignment(LabelHandler handler, ILabel label) => handler.NativeView?.UpdateHorizontalTextAlignment(label); - public static void MapLineBreakMode(LabelHandler handler, ILabel label) => + public static void MapVerticalTextAlignment(LabelHandler handler, ILabel label) => + handler.NativeView?.UpdateVerticalTextAlignment(label); + + public static void MapLineBreakMode(LabelHandler handler, ILabel label) => handler.NativeView?.UpdateLineBreakMode(label); public static void MapTextDecorations(LabelHandler handler, ILabel label) => @@ -49,7 +52,7 @@ public static void MapMaxLines(LabelHandler handler, ILabel label) => public static void MapPadding(LabelHandler handler, ILabel label) => handler.NativeView?.UpdatePadding(label); - public static void MapLineHeight(LabelHandler handler, ILabel label) => + public static void MapLineHeight(LabelHandler handler, ILabel label) => handler.NativeView?.UpdateLineHeight(label); } } diff --git a/src/Core/src/Handlers/Label/LabelHandler.cs b/src/Core/src/Handlers/Label/LabelHandler.cs index 776ec6721d79..b74567e351d1 100644 --- a/src/Core/src/Handlers/Label/LabelHandler.cs +++ b/src/Core/src/Handlers/Label/LabelHandler.cs @@ -11,6 +11,7 @@ public partial class LabelHandler [nameof(ILabel.CharacterSpacing)] = MapCharacterSpacing, [nameof(ILabel.Font)] = MapFont, [nameof(ILabel.HorizontalTextAlignment)] = MapHorizontalTextAlignment, + [nameof(ILabel.VerticalTextAlignment)] = MapVerticalTextAlignment, [nameof(ILabel.LineBreakMode)] = MapLineBreakMode, [nameof(ILabel.LineHeight)] = MapLineHeight, [nameof(ILabel.MaxLines)] = MapMaxLines, diff --git a/src/Core/src/Handlers/Label/LabelHandler.iOS.cs b/src/Core/src/Handlers/Label/LabelHandler.iOS.cs index 6f17041beafd..2602937c2930 100644 --- a/src/Core/src/Handlers/Label/LabelHandler.iOS.cs +++ b/src/Core/src/Handlers/Label/LabelHandler.iOS.cs @@ -41,6 +41,9 @@ public static void MapHorizontalTextAlignment(LabelHandler handler, ILabel label handler.NativeView?.UpdateHorizontalTextAlignment(label); } + [MissingMapper] + public static void MapVerticalTextAlignment(LabelHandler handler, ILabel label) { } + public static void MapLineBreakMode(LabelHandler handler, ILabel label) { handler.NativeView?.UpdateLineBreakMode(label); diff --git a/src/Core/src/Platform/Windows/AlignmentExtensions.cs b/src/Core/src/Platform/Windows/AlignmentExtensions.cs index b45efe69c7a8..30253a31b0c6 100644 --- a/src/Core/src/Platform/Windows/AlignmentExtensions.cs +++ b/src/Core/src/Platform/Windows/AlignmentExtensions.cs @@ -17,6 +17,19 @@ public static HorizontalAlignment ToNativeHorizontalAlignment(this TextAlignment } } + public static VerticalAlignment ToNativeVerticalAlignment(this TextAlignment alignment) + { + switch (alignment) + { + case TextAlignment.Center: + return VerticalAlignment.Center; + case TextAlignment.End: + return VerticalAlignment.Bottom; + default: + return VerticalAlignment.Top; + } + } + public static UI.Xaml.TextAlignment ToNative(this TextAlignment alignment, bool isLtr = true) { switch (alignment) diff --git a/src/Core/src/Platform/Windows/TextBlockExtensions.cs b/src/Core/src/Platform/Windows/TextBlockExtensions.cs index eea2d04c9d8a..507d3e25c92a 100644 --- a/src/Core/src/Platform/Windows/TextBlockExtensions.cs +++ b/src/Core/src/Platform/Windows/TextBlockExtensions.cs @@ -88,6 +88,11 @@ public static void UpdateHorizontalTextAlignment(this TextBlock nativeControl, I nativeControl.TextAlignment = label.HorizontalTextAlignment.ToNative(true); } + public static void UpdateVerticalTextAlignment(this TextBlock nativeControl, ILabel label) + { + nativeControl.VerticalAlignment = label.VerticalTextAlignment.ToNativeVerticalAlignment(); + } + public static void UpdateLineBreakMode(this TextBlock nativeControl, ILabel label) { var lineBreakMode = label.LineBreakMode;