Theme handling in Maui FlexGrid

Posted by: l.balazs on 31 January 2023, 9:13 pm EST

    • Post Options:
    • Link

    Posted 31 January 2023, 9:13 pm EST

    Android: the Maui FlexGrid control keeps its default colors (light) regardless the theme is changed from Light to Dark in the phone. How Can I fix this?

    Thanks,

    Louis

  • Posted 5 February 2023, 8:48 pm EST - Updated 5 February 2023, 8:53 pm EST

    Hi,

    C1 controls are independent of System Themes. You can apply AppThemeBinding accordingly to customize the view in Light or Dark mode.

    Please refer here: https://learn.microsoft.com/en-us/dotnet/maui/user-interface/system-theme-changes?view=net-maui-7.0

    You can apply AppThemeBinding for Flexgrid too:

        <ContentPage.Resources>
            <!-- Dark Theme colors -->
            <Color x:Key="DarkRowBackGround">DarkGray</Color>
            <Color x:Key="DarkAltRowBackGround">LightGray</Color>
            <Color x:Key="DarkPrimaryColor">Black</Color>
            <Color x:Key="DarkForegroundColor">White</Color>
    
        </ContentPage.Resources>
        <StackLayout>
            <c1:FlexGrid x:Name="grid"
                         BackgroundColor="{AppThemeBinding Dark={StaticResource DarkPrimaryColor}}"
                         RowBackground="{AppThemeBinding Dark={StaticResource DarkRowBackGround}}"
                         AlternatingRowBackground="{AppThemeBinding Dark={StaticResource DarkAltRowBackGround}}"
                         RowForeground="{AppThemeBinding Dark={StaticResource DarkForegroundColor}}"
                         ColumnHeaderBackground="{AppThemeBinding Dark={StaticResource DarkPrimaryColor}}"
                         ColumnHeaderForeground="{AppThemeBinding Dark={StaticResource DarkForegroundColor}}"
                         />
        </StackLayout>
    

    Please refer the sample for full implementation: FlexGridMAUI.zip

    Refer the gif for the same:

    As compared to WPF or Winforms, we do not support Themes for C1 MAUI controls directly. However, we have raised an enhancement to support Themes.[Internal Tracking Id - C1XAML-31147]

    Best Regards,

    Nitin

  • Posted 6 February 2023, 5:26 pm EST

    Thank you. It’s clear now.

    Louis

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels