Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New sample: Style geometry types with symbols #1524

Merged
merged 10 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions src/MAUI/Maui.Samples/Converters/ColorConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,28 @@ internal class ColorConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value == null || value.GetType() != typeof(string)) { return null; }
return Microsoft.Maui.Graphics.Color.FromArgb((string)value);
if (value == null) return null;

// Determine the object type.
Type type = value.GetType();

if (type == typeof(string))
{
string colorString = value as string;

// Color needs to be in hex format or else it will throw.
return Color.FromArgb(colorString);
}
else if (type == typeof(System.Drawing.Color))
{
var color = (System.Drawing.Color)value;

return new Color(color.R, color.G, color.B, color.A);
}
else
{
return null;
}
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Binary file not shown.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Binary file not shown.
Loading
Loading