I want to display an ActivityIndicator while doing some http calls.
In my view model I have a property
public bool ShowActivityIndicator { get; set; } = false;
A button command
public void UploadSurveyCommand()
{
ShowActivityIndicator = !ShowActivityIndicator; //TODO: change
}
In the Page
<Grid Padding="10">
<ActivityIndicator x:Name="activity"
IsVisible="{Binding ShowActivityIndicator}"
IsRunning="True"
Color="{StaticResource NavigationBarColor}" ZIndex="1000"
VerticalOptions="Center" HorizontalOptions="Center"
WidthRequest="100" HeightRequest="100"/>
<Button Text="{loc:Localize Upload}"
BackgroundColor="White"
TextColor="{StaticResource BtnColor}"
FontAttributes="Bold"
CornerRadius="30"
WidthRequest="250"
HeightRequest="50"
Margin="0,15,0,0"
Command="{Binding UploadSurveyCommand}"/>
</Grid>
When I press the button, and the ShowActivityIndicator value changes to true the ActivityIndicator is not shown.
I made a workaround:
In view model on the button event I added a
WeakReferenceMessenger.Where the message class has one property
On the page code behind I register a
WeekReferenceMessengerlistener and registered it in the constructor.Hope helps someone!