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

Set property to dynamically build XAML?

$
0
0

I have made a reusable button layout class which can range anywhere between 1-5 buttons. It is currently set up as a bunch of grid columns with buttons inside. The columns are built in a loop defined by the "number of columns prIn the class, I have it set to a default value of "3" but I want to be able to define the number of buttons in the XAML call where I use it.

My XAML page currently has this:

The code behind has this:

The text property changes, but the number of columns stays the default of 3. I'm assuming this is because the control builds and loops all its elements at the InitializeComponent() part.

How can I set the "num of columns" property so that I can override the default value at runtime before everything is built. Ideally, where I can put it in like:

...or if I can do this any other way. Thanks!


Viewing all articles
Browse latest Browse all 58056

Trending Articles



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