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

Why do I receive a System.TypeLoadException when setting Label font in StackLayout?

$
0
0

The Font = Font.SystemFontOfSize(NamedSize.Small) in the following code will cause a System.TypeLoadException. When I remove that code it works fine. Any ideas?

    using Xamarin.Forms;
    class TopBar : ContentView
    {
        public TopBar()
        {
            var stack = new StackLayout
            {
                Children =
                {
                    new Label() { Text = "Logo", TextColor = Color.White},
                    new StackLayout{
                        Orientation = StackOrientation.Vertical,
                        Children = {
                            new Label() { Text = "University of New York", HorizontalOptions = LayoutOptions.CenterAndExpand, XAlign = TextAlignment.Center, TextColor = Color.White},
                            new Label() { Text = "Alumni Section", HorizontalOptions = LayoutOptions.CenterAndExpand, XAlign = TextAlignment.Center, Font = Font.SystemFontOfSize(NamedSize.Small), TextColor = Color.White}
                        },
                        HorizontalOptions = LayoutOptions.CenterAndExpand,
                        Spacing = 0,
                    },
                    new Label() { Text = "Menu", TextColor = Color.White}
                },
                Orientation = StackOrientation.Horizontal,
                BackgroundColor = Color.FromHex("3b5998"),
                Padding = new Thickness(0, 1, 0, 3)
            };

            this.Content = stack;
        }
    }

Viewing all articles
Browse latest Browse all 58056

Trending Articles