我坚持将参数从视图模型传递到页面。在视图模型页面上,我有按按钮增加的属性列表,在按钮单击总和显示在下面的同一页面上之后,我收集了很多东西,我的目标是将在此视图模型页面上收集的总和发送到新页面我想负责显示这笔款项。我坚持传递参数,它只是不更新值,看起来绑定是好的,因为应用程序不会抛出对象没有引用的异常。我是 xamarin 的初学者,对于我可以遵循的任何解释或方向来实现这一点,我将不胜感激。先感谢您 :)列表视图模型代码: public class PersonListViewModel : INotifyPropertyChanged{ public ObservableCollection<PersonViewModel> Persons { get; set; } PersonViewModel selectedPerson; double _sumcollected; public double SumCollected { get => _sumcollected; set { if (_sumcollected != value) { _sumcollected = value; OnPropertyChanged("SumCollected"); } } } public INavigation Navigation { get; set; } public PersonListViewModel() { Persons = new ObservableCollection<PersonViewModel> { new PersonViewModel() { Name="Test", Surname="Test", Description= "TEsT", Background = "bgtest6.jpg", ProgressCounter =0.1, SavedClicked=0,Weight=1 }, new PersonViewModel() { Name="Test", Surname="Test", Description= "TEsT",Background = "bgtest6.jpg", ProgressCounter =0.1, SavedClicked=0,Weight=30 }, new PersonViewModel() { Name="Test", Surname="Test", Description= "TEsT",Background = "bgtest6.jpg", ProgressCounter =0.2, SavedClicked=0,Weight=100 }, new PersonViewModel() { Name="Test", Surname="Test", Description= "TEsT",Background = "bgtest6.jpg", ProgressCounter =0.3, SavedClicked=0,Weight=27 }, }; NavigateCommand = new Command<PersonViewModel>(NavigatationSolved); IncreaseProgressCommand = new Command<PersonViewModel>(IncreaseProgress); GotoCounterCommand = new Command<PersonListViewModel>(GotoNumbersPage); NavigateSumPageCommand = new Command<PersonListViewModel>(NavigateSumPage); }
1 回答
泛舟湖上清波郎朗
TA贡献1818条经验 获得超3个赞
您需要接收您在视图模型中传递的对象。
public CounterViewModel(PersonListViewModel personList) { PersonList = personList; }
- 1 回答
- 0 关注
- 128 浏览
添加回答
举报
0/150
提交
取消