我正在制作一个Xamarin应用程序,我有一个
ObservableCollection
被称为
Booking
在我的
BookingViewModel
是的。
public ObservableCollection<Data.Entities.Booking> Bookings { get; set; }
然后我有一个方法设置
Bookings
像这样的数据。
this.Bookings = BookingService.GetBookings(this.SearchCriteria);
然后在
预订
可观测集合
单击时显示
Popup
使用rg.plugins.popup。弹出窗口仅包含属性的输入字段
Bay
还有一个保存按钮。
但是,此弹出代码发生在名为
BayUpdatePopupViewModel
是的。在这里,我可以更新选定预订的间隔字段。这是正确的保存,但我需要通知
预订
可观测集合
其中一个项目已更新,而不必刷新列表。
这是我的救命稻草
Command
在
BayUpdatePopupViewModel
public ICommand OnSave => new Command(async () =>
{
var response = await BookingService.Update(this.Booking));
if (response.IsSuccessStatusCode)
{
await PopupNavigation.Instance.PopAsync();
}
});
我需要在之后调用通知代码
IsSuccessStatusCode
我想。
我的
预订
实体继承自
INotifyPropertyChanged
但我不知道如何引用
预订
可观测集合
从不同的视图模型。我怎样才能做到这一点?
编辑:
在我的showpopup命令中,im现在正在设置
Changed
方法到
BayUpdatePopupViewModel
是的。当我更新间隔值时
改变
方法实际上是由于它仍然没有用新值更新我的ui而触发的。
public ICommand ShowPopupCommand => new Command<Data.Entities.Booking>(async booking =>
{
this.BayUpdatePopupViewModel = new BayUpdatePopupViewModel(booking);
this.BayUpdatePopupViewModel.PropertyChanged += Changed;
await PopupNavigation.Instance.PushAsync(new BayUpdatePopupPage(this.BayUpdatePopupViewModel));
});
public void Changed(object sender, PropertyChangedEventArgs e)
{
OnPropertyChanged(nameof(this.Bookings));
}