Skip to content

Commit

Permalink
TextBlockExtensions: Use the new flag in UpdatePadding
Browse files Browse the repository at this point in the history
  • Loading branch information
MartyIX committed Sep 30, 2024
1 parent fb287bc commit f6c8ab0
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/Core/src/Platform/Windows/TextBlockExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using System.Xml.Linq;
using System.Xml.Resolvers;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Documents;

namespace Microsoft.Maui.Platform
{
Expand All @@ -31,8 +30,18 @@ public static void UpdateText(this TextBlock platformControl, ILabel label)
public static void UpdateTextColor(this TextBlock platformControl, ITextStyle text) =>
platformControl.UpdateProperty(TextBlock.ForegroundProperty, text.TextColor);

public static void UpdatePadding(this TextBlock platformControl, ILabel label) =>
platformControl.UpdateProperty(TextBlock.PaddingProperty, label.Padding.ToPlatform());
public static void UpdatePadding(this TextBlock platformControl, ILabel label)
{
var padding = label.Padding;

bool? skipInitialization = (label.Handler as ElementHandler)?._isInitializing ?? false
|| padding != Thickness.Zero;

if (skipInitialization != true)
{
platformControl.UpdateProperty(TextBlock.PaddingProperty, padding.ToPlatform());
}
}

public static void UpdateCharacterSpacing(this TextBlock platformControl, ITextStyle label)
{
Expand Down

0 comments on commit f6c8ab0

Please sign in to comment.