MvxListView不会绑定

时间:2013-08-04 10:57:29

标签: xamarin.android mvvmcross

我遇到了最奇怪的错误: 我有一个带有MvxListView的页面,这里是局部布局:

<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" />

当相应的ViewModel被加载时,我收到以下错误:

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

属性Dishes存在于viewmodel中:

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

我有一个方法用项目填充列表:

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

我在app中的不同视图中使用相同的逻辑只使用不同的类型

有什么想法吗?

1 个答案:

答案 0 :(得分:3)

块:

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

生成private Dishes属性 - 尝试在其前面添加public