1
votes

I like the idea of having a ListView and just bind data and specify a DataTemplate for list item layout. But here is where I dont get it. Say I have:

public class Order
{
    public int Id {get; set; }
    public string CustomerName { get; set; }
    public List<OrderItem> OrderItems  { get; set; }
}

public class OrderItem
{
    public string ItemName { get; set; }
}

So far so good. Now I want to populate a list in ListView which looks as follows:

(Orderid)

ItemName, ItemName

(Orderid)

ItemName, ItemName, ItemName

and so on.

Edit: I dont want to list the Order Id but I want to be able to fetch it on a click event in the list.

I cant find anywhere If I can bind a collection in a ViewCell. How should I go about this? Is there a way to have nested ViewCells in this matter?

/Mike

1

1 Answers

0
votes

I presume from your post that you are wanting the CustomerName to almost act as a section header.

You should look at the example here for creating grouped list views in Xamarin.Forms and you will be able to recreate the desired visual:

https://github.com/xamarin/xamarin-forms-samples/tree/master/LabelledSectionsList

Good luck