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

Xamarin.Forms Global Code Styles not working.

$
0
0

I have read the doc and I can't get the global styles to work in my Xamarin.Forms 1.3.1 sample app. I can get the page based styles and built in styles work but not the global. Am I doing something wrong? Probably.

Thanks for your help in advance. Adam

using System;
using Xamarin.Forms;

namespace StyleTest
{
    public class App : Application
    {
        public App ()
        {
            Application.Current.Resources = new ResourceDictionary ();

            var labelStyle = new Style (typeof(Label)) {
                Setters = {
                    new Setter { Property = Label.TextColorProperty, Value = Color.Green }
                }
            };

            Application.Current.Resources.Add ("labelStyle", labelStyle);

            MainPage = new ContentPage {
                Content = new StackLayout {
                    VerticalOptions = LayoutOptions.Center,
                    Children = {
                        new Label {
                            StyleId = "labelStyle",
                            XAlign = TextAlignment.Center,
                            Text = "Welcome to Xamarin Forms!"
                        }
                    }
                }
            };
        }
    }
}

Viewing all articles
Browse latest Browse all 77050

Trending Articles



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