diff --git a/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithFontAttributesAndFontFamily.png b/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithFontAttributesAndFontFamily.png index 87cadf350db2..15b7308d6840 100644 Binary files a/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithFontAttributesAndFontFamily.png and b/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithFontAttributesAndFontFamily.png differ diff --git a/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithFontAttributesAndFontSize.png b/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithFontAttributesAndFontSize.png index 5aa4c1d9b4ad..484ba382160c 100644 Binary files a/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithFontAttributesAndFontSize.png and b/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithFontAttributesAndFontSize.png differ diff --git a/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithFormattedTextAndLineBreakModeNoWrap.png b/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithFormattedTextAndLineBreakModeNoWrap.png index 5c28409eb1d8..92757cf5d4e9 100644 Binary files a/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithFormattedTextAndLineBreakModeNoWrap.png and b/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithFormattedTextAndLineBreakModeNoWrap.png differ diff --git a/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithFormattedTextWhenLineBreakModeTailTruncation.png b/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithFormattedTextWhenLineBreakModeTailTruncation.png index ccf2cce53f3c..d0c66e17153b 100644 Binary files a/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithFormattedTextWhenLineBreakModeTailTruncation.png and b/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithFormattedTextWhenLineBreakModeTailTruncation.png differ diff --git a/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithFormattedTextWhenLineBreakModeWordWrap.png b/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithFormattedTextWhenLineBreakModeWordWrap.png index b5fe59055b52..ad72dbe9ac8d 100644 Binary files a/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithFormattedTextWhenLineBreakModeWordWrap.png and b/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithFormattedTextWhenLineBreakModeWordWrap.png differ diff --git a/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithFormattedTextWhenTextDecorationsStrikethrough.png b/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithFormattedTextWhenTextDecorationsStrikethrough.png index b146971d2959..0cba92dbe2b2 100644 Binary files a/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithFormattedTextWhenTextDecorationsStrikethrough.png and b/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithFormattedTextWhenTextDecorationsStrikethrough.png differ diff --git a/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithFormattedTextWhenTextDecorationsUnderLine.png b/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithFormattedTextWhenTextDecorationsUnderLine.png index d10a752976de..57759a56df27 100644 Binary files a/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithFormattedTextWhenTextDecorationsUnderLine.png and b/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithFormattedTextWhenTextDecorationsUnderLine.png differ diff --git a/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithTextAndCharacterSpacing.png b/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithTextAndCharacterSpacing.png index 47fbbaecef62..998a58d57474 100644 Binary files a/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithTextAndCharacterSpacing.png and b/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithTextAndCharacterSpacing.png differ diff --git a/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithTextAndFontAttributes.png b/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithTextAndFontAttributes.png index aa740a5b3f59..7701981becf7 100644 Binary files a/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithTextAndFontAttributes.png and b/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithTextAndFontAttributes.png differ diff --git a/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithTextAndFontColor.png b/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithTextAndFontColor.png index c061aab60032..7edf6e1ce894 100644 Binary files a/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithTextAndFontColor.png and b/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithTextAndFontColor.png differ diff --git a/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithTextAndFontFamily.png b/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithTextAndFontFamily.png index 389c8fa3ff5f..3920b6fb22eb 100644 Binary files a/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithTextAndFontFamily.png and b/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithTextAndFontFamily.png differ diff --git a/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithTextAndFontSize.png b/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithTextAndFontSize.png index 3ee44da8e880..1f756936b3a4 100644 Binary files a/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithTextAndFontSize.png and b/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithTextAndFontSize.png differ diff --git a/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithTextAndLineBreakModeNoWrap.png b/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithTextAndLineBreakModeNoWrap.png index 8c1f0d92a074..6d39e1ef2c25 100644 Binary files a/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithTextAndLineBreakModeNoWrap.png and b/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithTextAndLineBreakModeNoWrap.png differ diff --git a/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithTextAndLineBreakModeTailTruncation.png b/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithTextAndLineBreakModeTailTruncation.png index 5a3e30c8cd56..877df34d059c 100644 Binary files a/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithTextAndLineBreakModeTailTruncation.png and b/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithTextAndLineBreakModeTailTruncation.png differ diff --git a/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithTextAndMaxlines.png b/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithTextAndMaxlines.png index 1400bd7c9fe2..67641d46f4c7 100644 Binary files a/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithTextAndMaxlines.png and b/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithTextAndMaxlines.png differ diff --git a/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithTextAndTextDecorations.png b/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithTextAndTextDecorations.png index b9a40b6ad7bf..20688d9951a1 100644 Binary files a/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithTextAndTextDecorations.png and b/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithTextAndTextDecorations.png differ diff --git a/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithTextAndTextTransform.png b/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithTextAndTextTransform.png index 916f3a808535..8786cd09b43d 100644 Binary files a/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithTextAndTextTransform.png and b/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithTextAndTextTransform.png differ diff --git a/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithTextAndTextType.png b/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithTextAndTextType.png index f0e5a1fb9c11..b5a7550a8c08 100644 Binary files a/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithTextAndTextType.png and b/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithTextAndTextType.png differ diff --git a/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithTextTypeAndCharacterSpacing.png b/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithTextTypeAndCharacterSpacing.png index 522c25e8bfac..2cb58e478dd9 100644 Binary files a/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithTextTypeAndCharacterSpacing.png and b/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithTextTypeAndCharacterSpacing.png differ diff --git a/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithTextTypeAndLineBreakModeWordWrap.png b/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithTextTypeAndLineBreakModeWordWrap.png index 5cf6281365f2..bcfd0ac9d329 100644 Binary files a/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithTextTypeAndLineBreakModeWordWrap.png and b/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithTextTypeAndLineBreakModeWordWrap.png differ diff --git a/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithTextWhenPaddingApplied.png b/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithTextWhenPaddingApplied.png index 2401af82c386..69ec9605c5c3 100644 Binary files a/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithTextWhenPaddingApplied.png and b/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithTextWhenPaddingApplied.png differ diff --git a/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithTextWhenVerticalAndHorizontalAlignmentCenter.png b/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithTextWhenVerticalAndHorizontalAlignmentCenter.png index a382e8e56066..318a305dac0d 100644 Binary files a/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithTextWhenVerticalAndHorizontalAlignmentCenter.png and b/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithTextWhenVerticalAndHorizontalAlignmentCenter.png differ diff --git a/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithTextWhenVerticalAndHorizontalAlignmentEnd.png b/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithTextWhenVerticalAndHorizontalAlignmentEnd.png index ea3187f6f6c1..cf5d229fb5b3 100644 Binary files a/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithTextWhenVerticalAndHorizontalAlignmentEnd.png and b/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithTextWhenVerticalAndHorizontalAlignmentEnd.png differ diff --git a/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithTextWhenVerticalAndHorizontalAlignmentStart.png b/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithTextWhenVerticalAndHorizontalAlignmentStart.png index 2a21fe618b69..9d1931ef39e3 100644 Binary files a/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithTextWhenVerticalAndHorizontalAlignmentStart.png and b/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithTextWhenVerticalAndHorizontalAlignmentStart.png differ diff --git a/src/Core/src/Platform/Windows/TextBlockExtensions.cs b/src/Core/src/Platform/Windows/TextBlockExtensions.cs index b428ac5305da..dbdac8bea75a 100644 --- a/src/Core/src/Platform/Windows/TextBlockExtensions.cs +++ b/src/Core/src/Platform/Windows/TextBlockExtensions.cs @@ -71,6 +71,10 @@ public static void UpdateLineHeight(this TextBlock platformControl, ILabel label { platformControl.LineHeight = label.LineHeight * platformControl.FontSize; } + else + { + platformControl.ClearValue(TextBlock.LineHeightProperty); + } } public static void UpdateHorizontalTextAlignment(this TextBlock platformControl, ILabel label) diff --git a/src/Core/tests/DeviceTests/Handlers/Label/LabelHandlerTests.Windows.cs b/src/Core/tests/DeviceTests/Handlers/Label/LabelHandlerTests.Windows.cs index 6c061e102ed1..afda73ba2b9e 100644 --- a/src/Core/tests/DeviceTests/Handlers/Label/LabelHandlerTests.Windows.cs +++ b/src/Core/tests/DeviceTests/Handlers/Label/LabelHandlerTests.Windows.cs @@ -3,6 +3,7 @@ using System.Threading.Tasks; using Microsoft.Maui.DeviceTests.Stubs; using Microsoft.Maui.Storage; +using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; using Microsoft.UI.Xaml.Media; using Xunit; @@ -81,6 +82,32 @@ public async Task EmbeddedFontFamilyIsCorrectForRendering(bool validateSize) } } + [Fact(DisplayName = "LineHeight Resets To Default")] + public async Task LineHeightResetsToDefault() + { + var label = new LabelStub + { + Text = "Test", + LineHeight = 3, + }; + + var handler = await CreateHandlerAsync(label); + + var values = await InvokeOnMainThreadAsync(() => + { + var initial = handler.PlatformView.ReadLocalValue(TextBlock.LineHeightProperty); + + label.LineHeight = -1; + handler.UpdateValue(nameof(ILabel.LineHeight)); + + var reset = handler.PlatformView.ReadLocalValue(TextBlock.LineHeightProperty); + return (Initial: initial, Reset: reset); + }); + + Assert.NotEqual(DependencyProperty.UnsetValue, values.Initial); + Assert.Equal(DependencyProperty.UnsetValue, values.Reset); + } + TextBlock GetPlatformLabel(LabelHandler labelHandler) => labelHandler.PlatformView;