Skip to content

Commit

Permalink
Fix fixed page background color in the Gallery (#14639)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsuarezruiz committed Apr 19, 2023
1 parent 41481e7 commit acc718e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
7 changes: 7 additions & 0 deletions src/Controls/samples/Controls.Sample/Pages/Base/BasePage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Windows.Input;
using Maui.Controls.Sample.Models;
using Microsoft.Maui.Controls;
using Microsoft.Maui.Graphics;

namespace Maui.Controls.Sample.Pages.Base
{
Expand All @@ -12,6 +13,12 @@ public class BasePage : ContentPage

public BasePage()
{
Application.Current.Resources.TryGetValue("LightBackgroundColor", out object lightBackgroundResource);
Application.Current.Resources.TryGetValue("DarkBackgroundColor", out object darkBackgroundResource);

if (lightBackgroundResource is Color lightBackgroundColor && darkBackgroundResource is Color darkBackgroundColor)
this.SetAppThemeColor(BackgroundColorProperty, lightBackgroundColor, darkBackgroundColor);

NavigateCommand = new Command(async () =>
{
if (SelectedItem != null)
Expand Down
1 change: 0 additions & 1 deletion src/Controls/samples/Controls.Sample/Pages/MainPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
xmlns:views="clr-namespace:Maui.Controls.Sample.Pages.Base"
xmlns:local="clr-namespace:Maui.Controls.Sample"
x:Name="HomePage"
BackgroundColor="{DynamicResource BackgroundColor}"
NavigationPage.IconColor="White"
Title="Gallery">
<views:BasePage.Resources>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
x:Class="Maui.Controls.Sample.Pages.SettingsPage"
xmlns:views="clr-namespace:Maui.Controls.Sample.Pages.Base"
xmlns:viewmodels="clr-namespace:Maui.Controls.Sample.ViewModels"
BackgroundColor="{DynamicResource BackgroundColor}"
Title="Settings">
<views:BasePage.Resources>
<ResourceDictionary>
Expand Down

0 comments on commit acc718e

Please sign in to comment.