Reputation: 2300
How can I populate Xaml with C# array (or list or dic) data like ng-repeat
in angular. So given I have the following:
var list = new List<string>() { "item1", "item2" };
And a xaml view:
<StackLayout ng-repeat="x in list">
<SomeTag>TextHere</SomeTag>
<SomeOtherTag Text="x"></SomeOtherTag>
</StackLayout>
Assuming SomeTag
and SomeOtherTag
are valid tag names, how can I recreate ng-repeat
behaviour in this. I am not looking for any dropdown boxes, I just want a looping mechanism
Upvotes: 1
Views: 483
Reputation: 7918
You're gonna need to use a ListView
with an ItemTemplate
. The ListView is the list itself, and then each item in your list of data will use the ItemTemplate to draw itself.
As i don't know if you're using Xamarin.iOS, Xamarin.Android or Xamarin.Forms, i can't give you a direct link to the documentation, but it should be easy to google.
I have personally created a listview as this in Xamarin.Forms, so i could potentially help more if you're also doing it with Xamarin.Forms.
Upvotes: 3