How to make a list of card-like views containing a variable number of elements?

joaomigueljoaomiguel USMember

I want to create a list that display these card-like views, based on this object:

public class Announcement
{
    public int Id { get; set; }
    public string Name { get; set; }
    public string Description { get; set; }
    public bool CanBuy { get; set; }
    public bool HasRCM { get; set; }
    public DateTime ExpireDate { get; set; }
    public string ImageName { get; set; }
    public Item[] Items { get; set; }
}
public class Item
{
    public int SAPCode { get; set; }
    public int CNPCode { get; set; }
    public string Name { get; set; }
    public string Presentation { get; set; }
    public string RCM { get; set; }
    public int Quantity { get; set; }
    public int Bonus { get; set; }
    public decimal Discount { get; set; }
    public decimal PvA { get; set; }
    public decimal PvP { get; set; }
}

The problem is that I can have an Announcement object with as little as a Name and ExpireDate to display, to a almost all its properties and a couple Item objects.
I've tried using a TableView with a few couple cells each with a different number of elements, but I couldn't get it to work with a random number of Item objects.
My latest attempt involves a custom UIView that takes an Announcement object and builds the card-like view. This approach however, besides not being 100% functional, doesn't "feel right", nor does it perform well.
With my very limited experience with iOS dev/Xamarin, I've ran out of ideas to try.

Is there a way to make what I'm trying to accomplish? Or does it not make sense in iOS/mobile?

Tagged:
Sign In or Register to comment.