Forum Xamarin.Forms

Bindable Grid in Xamarin.Forms

JakubKJakubK PLMember ✭✭

I'm creating a small 2048 clone to practise Xamarin.Forms with MVVM, and I've got a trouble with binding a Row and Column of each square to Grid.
Currently I'm using this ItemsControl:
https :// to achieve that.
It works, but it's not reactive at all, so I have to manually clear and fill ItemSource everytime I add or delete an item.
I know it's not the best solution, and it's not performant, my app is lagging everytime I do this.
Can You please suggest me a better option for that ? Maybe Xamarin.Forms already has something that will be useful here?
I will be very grateful for Your help.

Best Answer


  • JiriMatejkaJiriMatejka CZMember ✭✭✭

    I don't know this control but in general binding to a collection requires binding to ObservableCollection and implementing INotifyPropertyChanged interface.

  • JakubKJakubK PLMember ✭✭

    Yes, This is what I'm doing.
    I'm using ReactiveUI Framework for MVVM, it has it's own API that includes INotifyPropertyChanged, but adding or deleting items from collection does not trigger the UI to refresh, I even tried to raise PropertyChanged on that collection, but it does not help anyway.

  • JakubKJakubK PLMember ✭✭
    Accepted Answer

    Okay. I solved my problem by adding BindableLayout to my Grid.
    I did not even know that it's possible, because googling "Bindable Grid" didn't provide this Docs Page, which helped a lot:

Sign In or Register to comment.