예제 #1
0
        async Task ItemClickCommandExecuteAsync(string category)
        {
            if (IsBusy)
            {
                return;
            }

            Exception error = null;

            try
            {
                IsBusy = true;
                var jokePage = new JokePage();
                await jokePage.ViewModel.Initialize(category);

                await Navigation.PushAsync(jokePage);
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Error: " + ex);
                error = ex;
            }
            finally
            {
                IsBusy = false;
            }

            if (error != null)
            {
                await ShowAlertAsync("Error!", error.Message, "OK");
            }
        }
예제 #2
0
 public JokeViewModel(JokePage page)
 {
     FetchJokeCommand = new Command(FetchJoke);
     StoreJokeCommand = new Command(StoreJoke);
     _jokeLabel       = page.FindByName <Label>("LabelJoke");
     _restClient      = DependencyService.Get <IRestClient>();
     _persistor       = DependencyService.Get <IPersistor>();
 }
예제 #3
0
        /// <summary>
        /// Navigate to joke's detail page.
        /// </summary>
        /// <param name="sender">The control/object that raised the event.</param>
        /// <param name="e">Event Data.</param>
        /// <param name="j">Joke. Detail page will be opened about it.</param>
        private void JokeButton_Click(object sender, RoutedEventArgs e, Joke j)
        {
            JokePage jokePage = new JokePage(j, this, this.CurrentLoggedInUser);

            NavigationService.Navigate(jokePage);
        }