maui
maui copied to clipboard
Static Color methods not converting values e.g Color.FromRgba
Description
using static Color methods does not work for other forms of colors apart from the primary colors. E.g. Color.FromRgba both in C# and using FactoryMethod in xaml does not display the color on the app
Steps to Reproduce
-
Create a File, New .Net MAUI App
-
Add the flowing lines of code within the VerticalStackLayout
-
XAML:
<Frame IsClippedToBounds="True" HasShadow="False" CornerRadius="10" Margin="20"> <Frame.BackgroundColor> <Color x:FactoryMethod="FromRgba"> <x:Arguments> <x:Double>181</x:Double> <x:Double>128</x:Double> <x:Double>209</x:Double> <x:Double>0.5</x:Double> </x:Arguments> </Color> </Frame.BackgroundColor> <VerticalStackLayout Spacing="5"> <Entry Placeholder="All holdings"/> <Entry Placeholder="Select account"/> </VerticalStackLayout> </Frame>
-
Run the application
-
The background color is transparent
Version with bug
7.0.408 (current)
Last version that worked well
Unknown/Other
Affected platforms
Android
Affected platform versions
Android 12
Did you find any workaround?
No
Relevant log output
No response
For the overload of Color.FromRgba()
that takes doubles, the ranges of every channel is 0.0...1.0. Only the int
overload takes numbers in the range 0..255.
These are the supported overloads:
public static Color FromRgba(int red, int green, int blue, int alpha); // pass 0-255 for each value
public static Color FromRgba(float r, float g, float b, float a); // pass 0.0-1.0 for each value
public static Color FromRgba(double r, double g, double b, double a); // pass 0.0-1.0 for each value
public static Color FromRgba(string colorAsHex); // pass a hex string
Thanks @Eilon. I was actually using the wrong overload. It's working now.
@Eilon, Please I am getting the error below, this is affecting the UI from updating
XHR0032 The property "FactoryMethod" does not exist in the "http://schemas.microsoft.com/winfx/2009/xaml" namespace
On Hot Reload
So it works the first time when you run the app, but it doesn't work later during Hot Reload?
Yes for first time run, but No during Hot Reload
@Akinnagbe can you file a new issue about the second problem? (https://github.com/dotnet/maui/issues/9232#issuecomment-1210873566)
There isn't enough info here to follow up on the XAML hot reload issue. I think we'll need at least a XAML example? All we have is the error message XHR0032 The property "FactoryMethod" does not exist in the ... namespace
.
Thanks!