Created
February 20, 2020 12:27
-
-
Save grimorde/ad181d1040cd1f604450be4f33cbb676 to your computer and use it in GitHub Desktop.
Busy Indicator with converter to show a message
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
<?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