Reputation: 6188
I would like to add a scrollable menu to a mobile app page.
Here Transfer, Accounts, Payment and Transaction are generated from an XML file.
The rest is static layout.
I am using Xamarin.Forms.
I would like to know how to generate UI components dynamically and attach them to a placeholder using Xamarin.Forms.
Upvotes: 0
Views: 1849
Reputation: 124
i think you can use "Collection View" which is new feature of xamarin.forms or "bindable layout" to make it dynamic.
Upvotes: 0
Reputation: 374
Dynamic UI creation is simple like the people said and there are many examples. But i think the problem is creating your own control according to your needs. For example i ended up with writing my own button with image in it like this:
So you have to write a method that creates a vertical stack layout (lets say outer container),and add a horizontal container to that "outer container" (lets say inner container) than add an image and a label to this "inner container" and make "innerContainer.HorizontalOptions = LayoutOptions.Center" etc. If you want border it goes complicated :)
Vertical Stack (whole container)
->Vertical Stack (height 2px) upper border
->Horizontal Stack (to hold middle controls,left border,inner image and text holder, right border etc.)
->Horizontal Stack (width 2 px) left border
->Vertical Stack (layoutOptions=Fillandexpand)
->Image (layoutOptions=Center)
->Label (layoutOptions=Center)
->Horizontal Stack (width 2 px) right border
->Vertical Stack (height 2px) lower border
So you have to join the controls like this hierarcy. First think how can you draw your control with existing controls than code it :) Hope i made my self clear.
Upvotes: 2