I have a UWP application and I want to show a content dialog while loading data.
This is my loading dialog which is called via the LoadedCommand.
private async Task LoadDataAsync()
{
await dialogService.ShowLoadingDialogAsync();
await LoadPaymentsAsync(new PaymentListFilterChangedMessage { TimeRangeStart = DateTime.Now.AddYears(DEFAULT_MONTH_BACK) });
//Refresh balance control with the current account
await BalanceViewModel.UpdateBalanceCommand.ExecuteAsync();
await dialogService.HideLoadingDialogAsync();
}
I also tried to to call it via the DispatcherHelper:
private async Task LoadDataAsync()
{
await DispatcherHelper.ExecuteOnUIThreadAsync(async () =>
{
await dialogService.ShowLoadingDialogAsync();
await LoadPaymentsAsync(new PaymentListFilterChangedMessage { TimeRangeStart = DateTime.Now.AddYears(DEFAULT_MONTH_BACK) });
//Refresh balance control with the current account
await BalanceViewModel.UpdateBalanceCommand.ExecuteAsync();
await dialogService.HideLoadingDialogAsync();
});
}
But that didn't change anything. The method in the DialogService looks like this:
/// <summary>
/// Shows a loading Dialog.
/// </summary>
public async Task ShowLoadingDialogAsync(string? message = null)
{
// Be sure no other dialog is open.
await HideLoadingDialogAsync();
loadingDialog = new LoadingDialog { Text = message ?? Strings.LoadingLabel };
CoreApplicationView coreWindow = CoreApplication.MainView;
// Dispatcher needed to run on UI Thread
CoreDispatcher dispatcher = coreWindow.CoreWindow.Dispatcher;
// RunAsync all of the UI info.
await dispatcher.RunAsync(CoreDispatcherPriority.High,
async () =>
{
await loadingDialog.ShowAsync();
});
}
/// <summary>
/// Hides the previously opened Loading Dialog.
/// </summary>
public Task HideLoadingDialogAsync()
{
loadingDialog?.Hide();
return Task.CompletedTask;
}
Funny enough on other occasions, for example when I load data from a webservice instead of the database this does work without any issues.
question from:https://stackoverflow.com/questions/65870911/uwp-loading-indicator-does-not-appear