Skip to content

Instantly share code, notes, and snippets.

@RedTahr
Last active August 29, 2015 14:21
Show Gist options
  • Save RedTahr/f3fa74e815576a08a4d2 to your computer and use it in GitHub Desktop.
Save RedTahr/f3fa74e815576a08a4d2 to your computer and use it in GitHub Desktop.
Xamarin.Forms ActivityIndicator in code with FadeOut of indicator and FadeIn of content.
// Xamarin Evolve 2014: Extending Xamarin.Forms with Custom Controls - Jason Smith, Xamarin https://www.youtube.com/watch?v=pIZ8G47KPIM
protected async override void OnAppearing() {
base.OnAppearing();
var loadingView = new ActivityIndicator {
VerticalOptions = LayoutOptions.Center,
HorizontalOptions = LayoutOptions.Center,
IsRunning = true
};
if (initialLoad) {
var normalContent = Content;
Content = loadingView;
await Task.Delay(1500);
await loadingView.FadeTo(0, 100);
normalContent.Opacity = 0;
Content = normalContent;
await normalContent.FadeTo(1, 500);
initialLoad = false;
}
}
<ActivityIndicator IsVisible="{Binding IsBusy}" IsRunning="{Binding IsBusy}"
AbsoluteLayout.LayoutFlags="PositionProportional" AbsoluteLayout.LayoutBounds="0.5, 0.5, AutoSize, AutoSize" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment