【问题标题】:MvxListView will not bindMvxListView 不会绑定
【发布时间】:2013-08-05 05:12:21
【问题描述】:

我遇到了最奇怪的错误: 我有一个带有 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属性:

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));
        }
    }

我有相同的逻辑在我的应用程序的不同视图中工作,但类型不同

有什么想法吗?

【问题讨论】:

    标签: xamarin.android mvvmcross


    【解决方案1】:

    方块:

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

    产生一个private Dishes 属性 - 尝试在它前面添加一个public

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多