theMothaShip
theMothaShip

Reputation: 1211

Binding to TableLayout in Mvvmcross

Is there any example of binding any sort of collection to a TableLayout in android? I keep receiving the message/warning that binding failed for attribute ItemSource LocationQuantities. All of the other bindings to the view model work as normal, but the list doesn't bind to the TableLayout. At first I thought my problem was binding to a dictionary but I was able to bind to a dictionary with other Mvx layouts (listview etcs.)

I can't seem to find in any of the N+ code examples or anywhere else on the web where a TableLayout is actually used in an mvvmcross app. I'm sure I'm just doing something stupid simple wrong here.

<Mvx.MvxTableLayout
        p1:id="@+id/PartLocationQtyTable"
        p1:layout_width="fill_parent"
        p1:layout_height="wrap_content"
        p1:layout_below="@id/PartDetailPriceLayout"
        p1:padding="5.0dp"
        local:MvxBind="ItemSource LocationQuantities"
        />

I've tried the above as well as with a custom template. The above example just uses a list of strings. Any help would be appreciated

Upvotes: 4

Views: 998

Answers (1)

Stuart
Stuart

Reputation: 66882

The only obvious problem I can see with your code is that it uses ItemSource whereas all the list-based layouts use ItemsSource - see MvxTableLayout.cs#L89

Beyond that, I guess you'll also want to make sure that your templates for TableLayout are TableRows - so that they can be loaded as rows. Obviously we can't see your item templates currently as you've not included them in the question.

I've got to admit TableLayout isn't something I've ever personally used in a production project - just not something I've yet needed to use.

Upvotes: 4

Related Questions