Hi all,
My setup is like this:
1- I have a content page with a listview of items that each has a Score.
2- By tapping an item in the list it opens up a popup page with another listview of values.
I can easily pass SelectedItem.Id from the ContentPage to the Popup page. However, I do not know how to add the value from the Popup page listview to the Score in the ContentPage and update it.
Any help will be much appreciated.
This is my code in the PopupViewModel:
async void AddValue(int selectedValueID)
{
bool isUserAccept = await Application.Current.MainPage.DisplayAlert
("ValuePoints", "Would you like to add these points?", "OK", "Cancel");
if (isUserAccept)
{
_student.Score += _points.Mvalue;
//_studentRepository.UpdateScore(_student.Score); //Tried that but didn't work
_studentRepository.UpdateStudent(_student);
await Application.Current.MainPage.DisplayAlert
("Value Points", "Value points were added.", "OK", "Cancel");
await PopupNavigation.Instance.PopAsync();
}
}
MValue _selectedValueItem;
public MValue SelectedValueItem
{
get => _selectedValueItem;
set
{
if (value != null)
{
_selectedValueItem = value;
NotifyPropertyChanged("SelectedValueItem");
AddValue(value.MvalueID);
}
}
}