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

How to reference a StyleClass from the code-behind page?

$
0
0

This compiles just fine but blows up in the iOS simulator when the view loads:

                    public MyTestPage()
                    {
                        InitializeComponent();

                        int i = 1; int iLen = 16;
                        for (i = 1; i <= iLen; i++) {
                            Label label =new Label();
                            label.StyleClass.Add("BarL");  // Works if this line is commented out.
                            label.Text = "C";
                            C.Children.Add(label);
                        }
                    }

The StyleClass "BarL" is defined in an inline in the XAML page. So, why doesn't the code-behind know about it?


Viewing all articles
Browse latest Browse all 77050

Trending Articles



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