Skip to content

Instantly share code, notes, and snippets.

@grimorde
Created February 20, 2020 12:27
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 grimorde/ad181d1040cd1f604450be4f33cbb676 to your computer and use it in GitHub Desktop.
Save grimorde/ad181d1040cd1f604450be4f33cbb676 to your computer and use it in GitHub Desktop.
Busy Indicator with converter to show a message
<?xml version="1.0" encoding="utf-8" ?>
<ResourceDictionary
x:Class="MyApp.Styles.Indicator"
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml">
<ControlTemplate x:Key="MainTemplate">
<Grid BindingContext="{TemplateBinding BindingContext}">
<ContentPresenter Grid.Row="0" />
<!-- 'Busy' indicator -->
<StackLayout
Grid.Row="0"
BackgroundColor="{DynamicResource BackgroundIndicatorColor}"
HorizontalOptions="FillAndExpand"
IsVisible="{TemplateBinding BindingContext.IsBusy}"
VerticalOptions="FillAndExpand">
<StackLayout
HorizontalOptions="CenterAndExpand"
VerticalOptions="CenterAndExpand">
<Frame
Margin="10"
Padding="10"
CornerRadius="40"
HeightRequest="100"
WidthRequest="200">
<StackLayout>
<ActivityIndicator
BackgroundColor="Transparent"
HeightRequest="48"
HorizontalOptions="Center"
IsRunning="{TemplateBinding BindingContext.IsBusy}"
IsVisible="{TemplateBinding BindingContext.IsBusy}"
VerticalOptions="Center"
WidthRequest="48"
Color="{DynamicResource IndicatorColor}" />
<Label
IsVisible="{TemplateBinding BindingContext.IsBusyText,
Converter={StaticResource StringHasValueConverter}}"
HorizontalOptions="Center"
HorizontalTextAlignment="Center"
Style="{DynamicResource TextPrimaryColor}"
Text="{TemplateBinding BindingContext.IsBusyText}" />
</StackLayout>
</Frame>
</StackLayout>
</StackLayout>
</Grid>
</ControlTemplate>
</ResourceDictionary>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment