Skip to content

Instantly share code, notes, and snippets.

@juucustodio
Last active July 7, 2017 20:18
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 juucustodio/a95ca98604869daf99c7aaf36138b1f1 to your computer and use it in GitHub Desktop.
Save juucustodio/a95ca98604869daf99c7aaf36138b1f1 to your computer and use it in GitHub Desktop.
Exemplo de Loading - Código realizado no Code-Behind
using System;
using System.ComponentModel;
using System.Threading.Tasks;
using Xamarin.Forms;
namespace DemoLoading
{
public partial class MainPage : ContentPage, INotifyPropertyChanged
{
public MainPage()
{
InitializeComponent();
IsLoading = false;
BindingContext = this;
}
public async void Show(object sender, EventArgs e)
{
try
{
aparece();
//Chame sua função aqui
await Task.Delay(4000);
some();
}
catch (Exception ex)
{
some();
if (ex != null)
{
//Trate seu erro aqui
}
}
}
public async void aparece()
{
IsLoading = true;
}
public async void some()
{
IsLoading = false;
}
private bool isLoading;
public bool IsLoading
{
get
{
return this.isLoading;
}
set
{
this.isLoading = value;
RaisePropertyChanged("IsLoading");
}
}
public event PropertyChangedEventHandler PropertyChanged;
public void RaisePropertyChanged(string name)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(name));
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment