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

RC2 - The BackgroundColor of the BoxView does not work #6592

Closed
HausBJB opened this issue Apr 28, 2022 · 12 comments
Closed

RC2 - The BackgroundColor of the BoxView does not work #6592

HausBJB opened this issue Apr 28, 2022 · 12 comments
Labels
area-drawing Shapes, Borders, Shadows, Graphics, BoxView, custom drawing platform/android 🤖 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Milestone

Comments

@HausBJB
Copy link

HausBJB commented Apr 28, 2022

Description

The BoxView BackgroundColor doesn't work, it always stays gray even if you add a different color to it, It happens on Android

`

<VerticalStackLayout>
    <BoxView 
        WidthRequest="200"
        HeightRequest="200"
        BackgroundColor="Blue"/>
</VerticalStackLayout>

`

Repro
Repro

image

Steps to Reproduce

Cloning the attached repository and running the application on both Windows and Android, the BoxView will not change the BackgroundColor and will always remain gray.

Version with bug

Release Candidate 2 (current)

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Android 12 API 31

Did you find any workaround?

No response

Relevant log output

No response

@HausBJB HausBJB added s/needs-verification Indicates that this issue needs initial verification before further triage will happen t/bug Something isn't working labels Apr 28, 2022
@XamlTest XamlTest added s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage labels Apr 28, 2022
@XamlTest
Copy link

Verified this issue with Visual Studio Enterprise 17.3.0 Preview 1.0 [32427.455.main]. Repro on Windows and Android with above project.

@XamlTest XamlTest removed the s/needs-verification Indicates that this issue needs initial verification before further triage will happen label Apr 28, 2022
@jsuarezruiz
Copy link
Contributor

Cannot reproduce the issue on main branch
image

@HausBJB
Copy link
Author

HausBJB commented Apr 28, 2022

Hello jsuarezruiz,

well, as you can see in this ticket, I'm not alone. And that just got closed

#6443 (comment)

@Eilon Eilon added the legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor label Apr 28, 2022
@HausBJB
Copy link
Author

HausBJB commented May 3, 2022

Hello, I found out that it is due to the VerticalStackLayout

I use the VerticalStackLayout
then I have to set Color
<VerticalStackLayout> <Entry x:Name="testEntry" Text="hallo"></Entry> <Button Text="test" Clicked="OnCounterClicked"></Button> <BoxView WidthRequest="300" HeightRequest="300" Color="Red" BackgroundColor="Aqua"> </BoxView> </VerticalStackLayout>
image

use StackLayout does this also work with BackgroundColor
<StackLayout> <Entry x:Name="testEntry" Text="hallo"></Entry> <Button Text="test" Clicked="OnCounterClicked"></Button> <BoxView WidthRequest="300" HeightRequest="300" BackgroundColor="Aqua"> </BoxView> </StackLayout>

image

use StackLayout and Color, then Color overrides BackgroundColor
<StackLayout> <Entry x:Name="testEntry" Text="hallo"></Entry> <Button Text="test" Clicked="OnCounterClicked"></Button> <BoxView WidthRequest="300" HeightRequest="300" Color="Red" BackgroundColor="Aqua"> </BoxView> </StackLayout>

image

@Redth Redth added this to the 6.0.300-servicing milestone May 3, 2022
@Redth
Copy link
Member

Redth commented May 3, 2022

Please try using Border and avoiding BoxView for now.

@Redth
Copy link
Member

Redth commented May 3, 2022

@PureWeen /cc

@jsuarezruiz
Copy link
Contributor

@PureWeen /cc

Shane, cannot reproduce the issue:

Screenshot_1653560355

But has been reported more than once, could you try it?

<VerticalStackLayout>
    <StackLayout>
    <Entry x:Name="testEntry1" Text="hallo"></Entry>
    <Button Text="test1" ></Button>
    <BoxView WidthRequest="300" HeightRequest="300" BackgroundColor="Aqua"></BoxView>
</StackLayout>
<StackLayout>
    <Entry x:Name="testEntry2" Text="hallo"></Entry>
    <Button Text="test2"></Button>
    <BoxView WidthRequest="300" HeightRequest="300" Color="Red" BackgroundColor="Aqua"></BoxView>
</StackLayout>
</VerticalStackLayout>

@HausBJB
Copy link
Author

HausBJB commented May 27, 2022

Hello
This is how it looks for me as soon as I set the Color property it works.
Background color is ignored

only for me Test1 doesn't work at all

image

@HausBJB
Copy link
Author

HausBJB commented May 27, 2022

Hello, is that correct that the color overwrites the background color in test2? it looks the same to them
image

@MGohil
Copy link

MGohil commented Jun 17, 2022

I switched to <Rectangle /> to get this sorted for time being.

image

@HausBJB
Copy link
Author

HausBJB commented Jun 17, 2022

Thanks, that's exactly what I did. Nobody here seems to care.
I've already opened a ticket twice with the same problem and the new version doesn't work again
#7448

so i gave up

@hartez
Copy link
Contributor

hartez commented Jun 22, 2022

Earlier versions of MAUI.Controls had the "box is always gray" issue, but that should be fixed (if not already in Service Release 1, then definitely in Service Release 2, which should be released in the near future).

BoxView in Xamarin.Forms was weird, because BackgroundColor and Color were effectively the same property.

The BoxView in MAUI.Controls keeps both properties for backward compatibility. The actual implementation of BoxView in MAUI.Controls is literally just a <Rectangle/> under the hood. We recommend using the Rectangle because it doesn't have the confusing extra property.

If you specify only the BackgroundColor (or Background) property, then the Fill for the Rectangle will use that color. If you specify Color, the Color property will determine the Fill for the Rectangle. In other words, Color always wins.

@hartez hartez closed this as completed Jun 22, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Jul 23, 2022
@Eilon Eilon added area-controls-boxview area-drawing Shapes, Borders, Shadows, Graphics, BoxView, custom drawing and removed legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor area-controls-boxview labels May 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-drawing Shapes, Borders, Shadows, Graphics, BoxView, custom drawing platform/android 🤖 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

8 participants