diff --git a/Microsoft.Maui.Graphics.Controls.MultiTargeting.targets b/Microsoft.Maui.Graphics.Controls.MultiTargeting.targets
index b5eb19c..6ffb4d7 100644
--- a/Microsoft.Maui.Graphics.Controls.MultiTargeting.targets
+++ b/Microsoft.Maui.Graphics.Controls.MultiTargeting.targets
@@ -83,8 +83,8 @@
-
-
+
+
\ No newline at end of file
diff --git a/src/GraphicsControls/GraphicsControls.csproj b/src/GraphicsControls/GraphicsControls.csproj
index 9c06e69..c89dd26 100644
--- a/src/GraphicsControls/GraphicsControls.csproj
+++ b/src/GraphicsControls/GraphicsControls.csproj
@@ -12,7 +12,7 @@
Microsoft.Maui.Graphics.Controls
-
+
\ No newline at end of file
diff --git a/src/GraphicsControls/Handlers/Button/ButtonHandler.cs b/src/GraphicsControls/Handlers/Button/ButtonHandler.cs
index b758a0c..f5b25b3 100644
--- a/src/GraphicsControls/Handlers/Button/ButtonHandler.cs
+++ b/src/GraphicsControls/Handlers/Button/ButtonHandler.cs
@@ -11,10 +11,10 @@ namespace Microsoft.Maui.Graphics.Controls
public static PropertyMapper PropertyMapper = new PropertyMapper(ViewHandler.Mapper)
{
[nameof(IButton.Background)] = ViewHandler.MapInvalidate,
- [nameof(IButton.Text)] = ViewHandler.MapInvalidate,
- [nameof(IButton.TextColor)] = ViewHandler.MapInvalidate,
- [nameof(IButton.Font)] = ViewHandler.MapInvalidate,
- [nameof(IButton.CharacterSpacing)] = ViewHandler.MapInvalidate,
+ [nameof(IText.Text)] = ViewHandler.MapInvalidate,
+ [nameof(ITextStyle.TextColor)] = ViewHandler.MapInvalidate,
+ [nameof(ITextStyle.Font)] = ViewHandler.MapInvalidate,
+ [nameof(ITextStyle.CharacterSpacing)] = ViewHandler.MapInvalidate,
[nameof(IButton.Padding)] = ViewHandler.MapInvalidate
};
diff --git a/src/GraphicsControls/Handlers/Button/CupertinoButtonDrawable.cs b/src/GraphicsControls/Handlers/Button/CupertinoButtonDrawable.cs
index 4fdeab4..6f780c2 100644
--- a/src/GraphicsControls/Handlers/Button/CupertinoButtonDrawable.cs
+++ b/src/GraphicsControls/Handlers/Button/CupertinoButtonDrawable.cs
@@ -31,13 +31,15 @@
{
canvas.SaveState();
- canvas.FontColor = button.TextColor.WithDefault(Cupertino.Color.Label.Light.White);
+ var textColor = (button as ITextStyle)?.TextColor;
+ canvas.FontColor = textColor?.WithDefault(Cupertino.Color.Label.Light.White);
canvas.FontSize = 17f;
var height = dirtyRect.Height;
var width = dirtyRect.Width;
- canvas.DrawString(button.Text, 0, 0, width, height, HorizontalAlignment.Center, VerticalAlignment.Center);
+ var text = (button as IText)?.Text;
+ canvas.DrawString(text, 0, 0, width, height, HorizontalAlignment.Center, VerticalAlignment.Center);
canvas.RestoreState();
}
diff --git a/src/GraphicsControls/Handlers/Button/FluentButtonDrawable.cs b/src/GraphicsControls/Handlers/Button/FluentButtonDrawable.cs
index ef00dad..a345e7f 100644
--- a/src/GraphicsControls/Handlers/Button/FluentButtonDrawable.cs
+++ b/src/GraphicsControls/Handlers/Button/FluentButtonDrawable.cs
@@ -67,7 +67,10 @@
canvas.SaveState();
if (button.IsEnabled)
- canvas.FontColor = button.TextColor.WithDefault(Fluent.Color.Foreground.White);
+ {
+ var textColor = (button as ITextStyle)?.TextColor;
+ canvas.FontColor = textColor?.WithDefault(Fluent.Color.Foreground.White);
+ }
else
canvas.FontColor = Fluent.Color.Foreground.NeutralPrimary.ToColor();
@@ -76,7 +79,8 @@
var height = dirtyRect.Height;
var width = dirtyRect.Width;
- canvas.DrawString(button.Text, 0, 0, width, height, HorizontalAlignment.Center, VerticalAlignment.Center);
+ var text = (button as IText)?.Text;
+ canvas.DrawString(text, 0, 0, width, height, HorizontalAlignment.Center, VerticalAlignment.Center);
canvas.RestoreState();
}
diff --git a/src/GraphicsControls/Handlers/Button/MaterialButtonDrawable.cs b/src/GraphicsControls/Handlers/Button/MaterialButtonDrawable.cs
index eda7fc3..bc1a6d2 100644
--- a/src/GraphicsControls/Handlers/Button/MaterialButtonDrawable.cs
+++ b/src/GraphicsControls/Handlers/Button/MaterialButtonDrawable.cs
@@ -42,7 +42,8 @@ namespace Microsoft.Maui.Graphics.Controls
canvas.FontName = "Roboto";
- canvas.FontColor = button.TextColor.WithDefault(button.IsEnabled ? Material.Color.White : Material.Color.Gray1);
+ var textColor = (button as ITextStyle)?.TextColor;
+ canvas.FontColor = textColor?.WithDefault(button.IsEnabled ? Material.Color.White : Material.Color.Gray1);
canvas.FontSize = Material.Font.Button;
@@ -51,7 +52,8 @@ namespace Microsoft.Maui.Graphics.Controls
var width = dirtyRect.Width;
- canvas.DrawString(button.Text.ToUpper(), x, y, width, MaterialBackgroundHeight, HorizontalAlignment.Center, VerticalAlignment.Center);
+ var text = (button as IText)?.Text;
+ canvas.DrawString(text?.ToUpper(), x, y, width, MaterialBackgroundHeight, HorizontalAlignment.Center, VerticalAlignment.Center);
canvas.RestoreState();
}
diff --git a/src/GraphicsControls/Handlers/Entry/EntryHandler.cs b/src/GraphicsControls/Handlers/Entry/EntryHandler.cs
index 4ea36dd..bfe6460 100644
--- a/src/GraphicsControls/Handlers/Entry/EntryHandler.cs
+++ b/src/GraphicsControls/Handlers/Entry/EntryHandler.cs
@@ -71,7 +71,7 @@ namespace Microsoft.Maui.Graphics.Controls
{
if (!(Drawable is MaterialEntryDrawable))
return;
-
+
bool hasText = !string.IsNullOrEmpty(VirtualView.Text);
if (hasText)
diff --git a/src/GraphicsControls/Platform/ColorExtensions.cs b/src/GraphicsControls/Platform/ColorExtensions.cs
index 3c886e6..38600ee 100644
--- a/src/GraphicsControls/Platform/ColorExtensions.cs
+++ b/src/GraphicsControls/Platform/ColorExtensions.cs
@@ -7,7 +7,7 @@ namespace Microsoft.Maui.Graphics.Controls
{
public static Color WithDefault(this Color color, string defaultColor)
{
- if (!color.IsDefault())
+ if (color != null && !color.IsDefault())
return color;
else
return Color.FromArgb(defaultColor);