This is my ViewModel with bool and string property:
ViewModel : ValidatableBindableBase {
private bool _isBusy;
public bool IsBusy {
get { return _isBusy; }
set { SetProperty(ref _isBusy, value); }
}
private string _busyMessage;
public string BusyMessage {
get { return _busyMessage; }
set { SetProperty(ref _busyMessage, value); }
}
//Triggered when the button is clicked.
private async void Login() {
ShowBusyOverlay("Signing in");
// it will show if task.delay is added
//await Task.Delay(5000);
await loginService.SignIn();
}
private async void ShowBusyOverlay(string message) {
IsBusy = true;
BusyMessage = message;
}
}
XAML: NOTE: on Windows 10 15063 Visibility can bind bool property without converter
<Grid Grid.RowSpan="3" Grid.ColumnSpan="3" Visibility="{Binding Path=IsBusy, UpdateSourceTrigger=PropertyChanged}">
<Rectangle Fill="Black" Opacity="0.4" />
<StackPanel VerticalAlignment="Center" HorizontalAlignment="Center">
<ProgressRing IsActive="True" Width="40" Height="40"/>
<TextBlock Text="{Binding BusyMessage}" FontSize="20" FontWeight="Thin"/>
</StackPanel>
</Grid>
Target:
It doesn't show the Grid fast enough , so It will navigate to other page without showing it , how can I show that loading/grid as soon as the it goes to my ShowBusyOverlay? and is it advisable?