-1

I have a problem. I created the following class:

public class OrderBundles
{
    public int Id { get; set; }
    public NumOfTrades { get; set; }
    public List<Trade> Trades { get; set; }
}

public class Trade
{
    public int Id { get; set; }
    public string Date { get; set; }
    public string Action { get; set; }
    public string Coin { get; set; }
    public decimal Price { get; set; }
    public string ProfitUSDT { get; set; }
}

Now the bundles are working as follows: A bundle contains a SellOrder at first and then all Buy orders that are connected to a Sell.

Using that I want to create the following: enter image description here

Now I already created a CollectionView with a ViewModel attached to it, but the problem then is, how can I loop inside the CollectionView row through the other list, so I can use the RowSpan?

Any ideas?

Ferran Buireu
  • 28,630
  • 6
  • 39
  • 67
A. Vreeswijk
  • 822
  • 1
  • 19
  • 57
  • What do you mean to "loop inside the CollectionView, to use the RowSpan"? – Mihail Duchev Jun 04 '20 at 07:30
  • As you can see I want a RowSpan on the SellProfit column, that needs to overlap all the buys below it. Now all the rows the ProfitUSDT has to overlap is inside the Trades list. That means that the `RowSpan of the ProfitUSDT = Trades.Count` If I only use a CollectionView I can't set the RowSpawn, because each row has its own grid. – A. Vreeswijk Jun 04 '20 at 08:06

1 Answers1

1

Sorry , i misunderstood your question , so actually your problem is equal to is it possible to create bind on attached property(Grid.RowSpan) , xamarin does not support the feature for now .

Refer

Binding to Attached Properties in Xamarin Forms https://github.com/xamarin/Xamarin.Forms/issues/1647

Update

You could create a custom view as CollectionView.ItemTemplate , set rowSpan in method BindingContextChanged programatically .

   public CustomGrid()
    {
        InitializeComponent();
        this.BindingContextChanged += View1_BindingContextChanged;
    }

    private void View1_BindingContextChanged(object sender, EventArgs e)
    {
        OrderBundles obj = this.BindingContext;

        Grid.SetRowSpan(profitLabel, obj.Trades.Count);
    }

enter image description here

Sample link:https://github.com/ColeXm/GridSample

ColeX
  • 14,062
  • 5
  • 43
  • 240