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

Using bindings or working with lists inside lists

$
0
0

I think my question is simple so I will write it with pseudocode

Assuming I have this object

class object1
{
List myList;
String title;
}

Now, if I attach this to a listview with a custom datatemplate,
on my data template I can do:

Label myLabel = new Label();
lbl.setBinding(label.textProperty, "title");

But how can I work with all the List that is inside this DataSource?
To make myself more clear I want to do something like this in my data template

for ( int i in myList )
{
    Label intLabel = new Label();
    intLabel.setBinding(label.textProperty, "i");  // this will never work
    myStackLayout.Children.Add(intLabel);
}

I can try to make a Value Converter but I dont think this is the best way to achieve my goal.
Any thoughts?

Thank you.

--- EDIT ---

I might have wrote a bad example
what I Intend to use is not a List myList; but rather something more complex like a List myList;
Where object2 could have several properties just like object 1

class object2 
{
   string myString;
   int myInt;
    ....
}

Viewing all articles
Browse latest Browse all 58056

Trending Articles