0
我正在使用xamarin表单的移动应用程序,我有一个对象列表。我已经添加列表中的行,并使用此OnPropertyChanged并提高属性保存项目后,我想更新对象属性列表的状态。我们怎样才能更新状态属性,这里是我的代码示例,请检查代码并更新我,谢谢: -更新xamarin表格中的类属性
class Test
{
public int ID{ get; set; }
public string Name { get; set; }
public bool Status { get; set; }
}
class Consume : BaseViewModel
{
void main()
{
ObservableCollection<Test> coll = new ObservableCollection<Test>();
coll = await db.GetData();
foreach (var item in coll)
{
item.Status = true;
//How we can update Status property of class
OnPropertyChanged("Status");
}
}
}
,是的,我已经在BaseViewModel中实现了INotifyPropertyChanged。以便我使用此方法更新属性** OnPropertyChanged(“状态”); **但未更新状态。 –
'Test'和'BaseViewModel'是不同的类。从视图模型中,您可以更新放置在视图模型中的属性。您应该在'Test'类中实现'INotifyPropertyChanged'来更新'Test'中的'Status'。 –
谢谢@Egor Gromadskiy –