Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

Adding value from a popup page to ContentPage

$
0
0

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);
            }
        }
    }

Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>