Created
October 22, 2018 22:42
-
-
Save icebeam7/d741a1f26b85958960a512e4d99732fe to your computer and use it in GitHub Desktop.
MyStore.EmployeesApp: CustomerListPage.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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