Amit Raz
Amit Raz

Reputation: 5536

MvxListView will not bind

I am having the strangest error: I have a page with an MvxListView in it here is the partial layout:

<Mvx.MvxListView
            android:id="@+id/RatingsList"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            local:MvxBind="ItemsSource Path=Dishes"
            local:MvxItemTemplate="@layout/userpagedishtemplate"
            style="@style/ToolBarImage"
            android:background="#ffffffff" />

When the corresponding ViewModel gets loaded I get the following error:

[MvxBind]  24.32 Unable to bind: source property source not found Cirrious.MvvmCross.Binding.Parse.PropertyPath.PropertyTokens.MvxPropertyNamePropertyToken on RestaurantPageViewModel

The property Dishes exists in the viewmodel:

List<DishViewModel> _dishes = new List<DishViewModel>();    
    List<DishViewModel> Dishes
    {
        get
        {
            return _dishes;
        }
        set
        {
            _dishes = value;
            RaisePropertyChanged (() => Dishes);
        }
    }

And I have a method that fills the list with items:

private void LoadDishesFromWeb()
    {
        List<Dish> dishes = CommunicationManager.Restaurnats.GetDishListForRestaurnat (Restaurant.ID);
        foreach (var item in dishes)
        {
            Dishes.Add (new DishViewModel (item));
        }
    }

I have the same logic working in a different view in my app only with different types

Any ideas?

Upvotes: 1

Views: 1166

Answers (1)

Stuart
Stuart

Reputation: 66882

The block:

List<DishViewModel> Dishes 
{
    get
    {
        return _dishes;
    }
    set
    {
        _dishes = value;
        RaisePropertyChanged (() => Dishes);
    }
}

produces a private Dishes property - try adding a public word in front of it

Upvotes: 3

Related Questions