Why is this View not correctly binding to this ViewModel?

Deadly 提交于 2019-12-06 16:29:00

The problem is that you are trying to bind to CustomerViewModel.GetAll(), when GetAll in CustomerViewModel is a static function not an instance property.

Change the static function to something like this (in CustomerViewModel):

public ObservableCollection<Customer> GetAll
{
    get { return Customer.GetAll(); }
}

The problem is that CustomersViewModel .GetAll() is a static method. Binding only works with instance properties. You should move the implementation of GetAll() to the constructor, and then expose the collection as an instance property of the class.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!