Skip to content

BoxView BackgroundColor always gray #8972

Closed

Description

@tchtang

Description

following lesson
https://docs.microsoft.com/en-us/learn/modules/customize-xaml-pages-layout/4-arrange-views-stacklayout

1

result always gray color

2

Steps to Reproduce

xaml is

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="Notes.NewPage1"
             Title="NewPage1">
    <StackLayout x:Name="stack" Spacing="10">
    </StackLayout>
</ContentPage>

code behind is

namespace Notes;

public partial class NewPage1 : ContentPage
{
    public NewPage1()
    {
        InitializeComponent();

        var a = new BoxView { BackgroundColor = Colors.Red, HeightRequest = 40 };
        var b = new BoxView { BackgroundColor = Colors.Green, HeightRequest = 40 };
        var c = new BoxView { BackgroundColor = Colors.Yellow, HeightRequest = 40 };

        stack.Children.Add(a);
        stack.Children.Add(b);
        stack.Children.Add(c);
    }
}

Version with bug

6.0.400

Last version that worked well

Unknown/Other

Affected platforms

Android, Windows

Affected platform versions

pixel 5 api 30, window 10

Did you find any workaround?

No response

Relevant log output

No response

Activity

  1. added
    s/needs-verificationIndicates that this issue needs initial verification before further triage will happen
    t/bugSomething isn't working
    on Jul 25, 2022
  2. added
    legacy-area-controlsLabel, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor
    and removed
    s/needs-verificationIndicates that this issue needs initial verification before further triage will happen
    on Jul 25, 2022
  3. added this to the 6.0-servicing milestone on Jul 25, 2022
  4. self-assigned this
    on Aug 17, 2022
  5. jsuarezruiz commented on Aug 17, 2022

    @jsuarezruiz
    Contributor

    Cannot reproduce the issue in the current .net6.0 branch:

    image

    @jfversluis Could you try it when you can?. Thanks.

  6. tchtang commented on Aug 18, 2022

    @tchtang
    Author

    image

    image

    <ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
                 xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                 x:Class="MauiApp3.MainPage">
    
        <VerticalStackLayout>
            <BoxView BackgroundColor ="Aqua" HeightRequest="50" />
            <BoxView Background="Purple"  HeightRequest="50" />
            <BoxView BackgroundColor ="Red" HeightRequest="50" />
            <BoxView BackgroundColor ="Green" HeightRequest="50" />
            <BoxView BackgroundColor ="Yellow" HeightRequest="50" />
        </VerticalStackLayout>
    </ContentPage>
    

    image

    Microsoft Visual Studio Professional 2022
    Version 17.3.0 Preview 6.0
    VisualStudio.17.Preview/17.3.0-pre.6.0+32728.150
    Microsoft .NET Framework
    Version 4.8.09037

    Installed Version: Professional

    Visual C++ 2022 00483-00000-00004-AA809
    Microsoft Visual C++ 2022

    ASP.NET and Web Tools 17.3.375.53775
    ASP.NET and Web Tools

    Azure App Service Tools v3.0.0 17.3.375.53775
    Azure App Service Tools v3.0.0

    C# Tools 4.3.0-3.22375.15+456937d952ad5c0930293ef32c4fbf8c844a9fef
    C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

    CodeMaid 12.0
    CodeMaid is an open source Visual Studio extension to cleanup and simplify our C#, C++, F#, VB, PHP, PowerShell, R, JSON, XAML, XML, ASP, HTML, CSS, LESS, SCSS, JavaScript and TypeScript coding.

    Common Azure Tools 1.10
    Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

    Extensibility Message Bus 1.2.6 (master@34d6af2)
    Provides common messaging-based MEF services for loosely coupled Visual Studio extension components communication and integration.

    Microsoft JVM Debugger 1.0
    Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

    Mono Debugging for Visual Studio 17.3.20 (3f4cb00)
    Support for debugging Mono processes with Visual Studio.

    NuGet Package Manager 6.3.0
    NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/

    Razor (ASP.NET Core) 17.0.0.2232702+e1d654e792aa2fe6646a6935bcca80ff0aff4387
    Provides languages services for ASP.NET Core Razor.

    SQL Server Data Tools 17.0.62207.04100
    Microsoft SQL Server Data Tools

    Test Adapter for Boost.Test 1.0
    Enables Visual Studio's testing tools with unit tests written for Boost.Test. The use terms and Third Party Notices are available in the extension installation directory.

    Test Adapter for Google Test 1.0
    Enables Visual Studio's testing tools with unit tests written for Google Test. The use terms and Third Party Notices are available in the extension installation directory.

    TypeScript Tools 17.0.10701.2001
    TypeScript Tools for Microsoft Visual Studio

    Visual Basic Tools 4.3.0-3.22375.15+456937d952ad5c0930293ef32c4fbf8c844a9fef
    Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

    Visual F# Tools 17.1.0-beta.22363.4+1b94f89d4d1f41f20f9be73c76f4b229d4e49078
    Microsoft Visual F# Tools

    Visual Studio IntelliCode 2.2
    AI-assisted development for Visual Studio.

    VisualStudio.DeviceLog 1.0
    Information about my package

    VisualStudio.Mac 1.0
    Mac Extension for Visual Studio

    VSPackage Extension 1.0
    VSPackage Visual Studio Extension Detailed Info

    Xamarin 17.3.0.295 (d17-3@321c85a)
    Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

    Xamarin Designer 17.3.0.208 (remotes/origin/d17-3@e4f67afef)
    Visual Studio extension to enable Xamarin Designer tools in Visual Studio.

    Xamarin.Android SDK 13.0.0.0 (d17-3/030cd63)
    Xamarin.Android Reference Assemblies and MSBuild support.
    Mono: dffa5ab
    Java.Interop: xamarin/java.interop/d17-3@7716ae53
    SQLite: xamarin/sqlite@df4deab
    Xamarin.Android Tools: xamarin/xamarin-android-tools/main@14076a6

  7. prok155 commented on Aug 25, 2022

    @prok155

    I also face the same issue. BoxView is always dark and I can't change BackgroundColor. I use 6.0.486 version.

  8. modified the milestones: 6.0-servicing, Backlog on Aug 30, 2022
  9. jsuarezruiz commented on Sep 14, 2022

    @jsuarezruiz
    Contributor

    Could you try with the latest .NET MAUI version?. Cannot reproduce the issue with the latest version.
    image

  10. 3 remaining items

  11. tchtang commented on Sep 19, 2022

    @tchtang
    Author

    today did uninstall visual studio, restart laptop, reinstall not 100% successful but choose to continue

  12. m-faircloth commented on Dec 16, 2022

    @m-faircloth

    This was happening to me too. When starting a new Maui project and adding a BoxView, it was always these colors listed in the default styles.xaml. I changed the Property to BackgroundColor and it begin recognizing the custom colors I applied.

    styles

  13. moved this to In Progress in MAUI SDK Ongoingon Feb 15, 2023
  14. moved this from In Progress to Done in MAUI SDK Ongoingon Feb 15, 2023
  15. modified the milestones: Backlog, 8.0-preview1 on Feb 22, 2023
  16. ghost locked as resolved and limited conversation to collaborators on Mar 24, 2023
  17. added
    area-drawingShapes, Borders, Shadows, Graphics, BoxView, custom drawing
    and removed
    legacy-area-controlsLabel, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor
    on May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions