Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

Using Implicit Styles to Specify Background Color of All Pages

$
0
0

I am attempting to use App.xaml as sort of a stylesheet but having an issue with adding an implicit style to change the background color of all pages in my app to be the same color. I still always get white as the background color.

App.xaml:

<?xml version="1.0" encoding="utf-8" ?>
<Application
    xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    x:Class="MyApp">
  <Application.Resources>
    <ResourceDictionary>
      <Style TargetType="Page">
        <Setter Property="BackgroundColor" Value="#226E8A" />
      </Style>
    </ResourceDictionary>
  </Application.Resources>
</Application>

App.xaml.cs:

public partial class App : Application
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="App"/> class.
        /// </summary>
        public App()
        {
            InitializeComponent();

            // The root page of your application
            MainPage = new ContentPage
            {
                Content = new StackLayout
                {
                    VerticalOptions = LayoutOptions.Center,
                    Children = {
                        new Label {
                            XAlign = TextAlignment.Center,
                            Text = "Welcome to the App!"
                        }
                    }
                }
            };
        }
}

Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>