Last active
July 7, 2017 20:18
-
-
Save juucustodio/a95ca98604869daf99c7aaf36138b1f1 to your computer and use it in GitHub Desktop.
Exemplo de Loading - Código realizado no Code-Behind
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 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