Skip to content

Instantly share code, notes, and snippets.

@icebeam7
Created October 22, 2018 22:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save icebeam7/d741a1f26b85958960a512e4d99732fe to your computer and use it in GitHub Desktop.
Save icebeam7/d741a1f26b85958960a512e4d99732fe to your computer and use it in GitHub Desktop.
MyStore.EmployeesApp: CustomerListPage.cs
using System;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
using MyStore.Models;
using MyStore.Services;
namespace MyStore.EmployeesApp.Pages
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class CustomerListPage : ContentPage
{
public CustomerListPage ()
{
InitializeComponent ();
}
protected async override void OnAppearing()
{
base.OnAppearing();
Loading(true);
CustomersListView.ItemsSource = await StoreWebApiClient.Instance.GetItems<CustomerDTO>("Customers");
Loading(false);
}
void Loading(bool show)
{
indicator.IsEnabled = show;
indicator.IsRunning = show;
}
private async void CustomersListView_ItemSelected(object sender, SelectedItemChangedEventArgs e)
{
try
{
var item = (CustomerDTO)e.SelectedItem;
await Navigation.PushAsync(new CustomerPage(item));
CustomersListView.SelectedItem = null;
}
catch (Exception ex)
{
}
}
public async void AddButton_Clicked(object sender, EventArgs e)
{
await Navigation.PushAsync(new CustomerPage(new CustomerDTO()));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment