I want to set the colour of the whole background of my app.
I tried to use a ResourceDictionary Theme and use it in App.xaml like:
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Resources/Styles/Colors.xaml" />
<ResourceDictionary Source="Resources/Styles/Styles.xaml" />
<ResourceDictionary Source="Resources/Themes/LightTheme.xaml" />
</ResourceDictionary.MergedDictionaries>
I tried use a Colour ResourceDictionary for all ContentPages in App.xaml like:
<Style TargetType="ContentPage">
<Setter Property="BackgroundColor" Value="{StaticResource S2H-Cream}" />
</Style>
But so far nothing worked. I couldn't find any helpful working advice neither in ms documentation not on stackoverflow.
I want to set the colour of the whole background of my app.
I tried to use a ResourceDictionary Theme and use it in App.xaml like:
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Resources/Styles/Colors.xaml" />
<ResourceDictionary Source="Resources/Styles/Styles.xaml" />
<ResourceDictionary Source="Resources/Themes/LightTheme.xaml" />
</ResourceDictionary.MergedDictionaries>
I tried use a Colour ResourceDictionary for all ContentPages in App.xaml like:
<Style TargetType="ContentPage">
<Setter Property="BackgroundColor" Value="{StaticResource S2H-Cream}" />
</Style>
But so far nothing worked. I couldn't find any helpful working advice neither in ms documentation not on stackoverflow.
Share Improve this question edited Mar 13 at 8:50 Julian 9,0575 gold badges29 silver badges60 bronze badges asked Mar 10 at 13:13 DuraDura 832 silver badges12 bronze badges 3- When you say the whole background of your app what do you mean? Background of all pages? because that's what you are doing here – FreakyAli Commented Mar 10 at 13:46
- 1 I highly recommend you look at a question about theming a .NET MAUI application and the answer I posted there: stackoverflow/questions/78833650/maui-dynamic-ui-changes – Stephen Quan Commented Mar 11 at 4:23
- Did you mean the app stil has some other background color in the page? I have tried your code and the shell navigation bar was the other color. In addition, did you set the backgorund color for the layout that filled the page? – Liyun Zhang - MSFT Commented Mar 17 at 5:33
1 Answer
Reset to default 0There are a lot of background colors that you can modify. Check your Styles.xaml.
below is a sample.
<Style TargetType="Page" ApplyToDerivedTypes="True">
<Setter Property="BackgroundColor" Value="{AppThemeBinding Light={StaticResource BackgroundColor}, Dark={StaticResource Black}}" />
</Style>
<Style TargetType="Shell" ApplyToDerivedTypes="True">
<Setter Property="Shell.BackgroundColor" Value="{AppThemeBinding Light={StaticResource Primary}, Dark={StaticResource Gray950}}" />
</Style>
<Style TargetType="NavigationPage">
<Setter Property="BarBackgroundColor" Value="{AppThemeBinding Light={StaticResource Primary}, Dark={StaticResource Gray950}}" />
</Style>
<Style TargetType="TabbedPage">
<Setter Property="BarBackgroundColor" Value="{AppThemeBinding Light={StaticResource White}, Dark={StaticResource Gray950}}" />
</Style>
Is this what are you looking for?
Hope that helps!