public override void OnNavigatedTo(object parameter, NavigationMode mode, IDictionary <string, object> state)
        {
            if (state.Any())
            {
                // clear any cache
                state.Clear();
            }
            else
            {
                // use navigation parameter
                var locator       = XamlUtil.GetResource <ViewModelLocator>("Locator", null);
                var peopleService = locator.PeopleService;

                var people = peopleService.People;

                _personViewModel = people.FirstOrDefault(p => p.Person.Id == parameter.ToString());

                if (_personViewModel != null)
                {
                    IsLoading = true;
                    Shell.SetBusyVisibility(Visibility.Visible, "Loading...");
                    peopleService.LoadDetails(_personViewModel.Person)
                    .ContinueWith(t =>
                    {
                        IsLoading = false;
                        Shell.SetBusyVisibility(Visibility.Collapsed);
                    });

                    var currentRank = _personViewModel.Person.Stats.Rank;
                    _prev = people.FirstOrDefault(p => p.Person.Stats.Rank == currentRank - 1);
                    _next = people.FirstOrDefault(p => p.Person.Stats.Rank == currentRank + 1);
                }
            }
        }
Beispiel #2
0
        public MainPageViewModel()
        {
            if (Windows.ApplicationModel.DesignMode.DesignModeEnabled)
            {
                // designtime data
                return;
            }

            SortByRankCommand = new DelegateCommand(() => ChangeSort(PeopleSort.Rank));
            SortByNameCommand = new DelegateCommand(() => ChangeSort(PeopleSort.Name));

            var locator = XamlUtil.GetResource <ViewModelLocator>("Locator", null);

            _peopleService = locator.PeopleService;
        }