将嵌套的对象列表绑定到列表视图

时间:2018-07-11 09:29:21

标签: listview xamarin data-binding xamarin.forms

我有三个类似的类..一个客户可以接收多个订单,每个订单有多个项目,每个项目都有多个属性,我希望两个在列表视图中显示..所以我发现在两个视图上滚动时android会导致错误,并且应用程序将崩溃.. 所以我的问题是绑定数据并循环显示xaml页面中具有item和items属性的嵌套订单列表的最佳方法是什么?

viewModel

 public class PageViewModel
{
    private ObservableCollection<CustomerOrders> _requestedItems;

    public ObservableCollection<CustomerOrders> RequestedItems
    {
        get => _requestedItems;
        set
        {
            if (Equals(value, _requestedItems)) return;
            _requestedItems = value;
            OnPropertyChanged();
        }
    }

    public ICommand GetRequestedItems
    {

        get
        {
            return new Command(async () =>
            {
                IsLoading = true;
                var accesstoken = Settings.AccessToken;
                RequestedItems = await _apiServices.GetCustomerDownloadOrdersAsync(accesstoken);


            });
        }
    }

}

 public class CustomerOrders
{
    public int Id { get; set; }

    public string RequestUserName { get; set; }

    public List<DownloadOrderItem> RequestedItemInfo { get; set; }

}


  public class DownloadOrderItem
{
    public int Id { get; set; }

    public int OrderId { get; set; }

    public string Name { get; set; }

    public string Url { get; set; }

}

0 个答案:

没有答案