UWP Loading indicator does not appear
During the testing, The LoadingDialog
Text property cause the problem, if you want make Text property could effect for xaml content, please make it as dependency property like the following.
Xaml
<Grid>
<TextBlock
x:Name="main_content"
VerticalAlignment="Center"
Text="{x:Bind Text, Mode=OneWay}" />
</Grid>
Code Behind
public sealed partial class LoadingDialog : ContentDialog
{
public LoadingDialog()
{
this.InitializeComponent();
}
public string Text
{
get { return (string)GetValue(TextProperty); }
set { SetValue(TextProperty, value); }
}
// Using a DependencyProperty as the backing store for Text. This enables animation, styling, binding, etc...
public static readonly DependencyProperty TextProperty =
DependencyProperty.Register("Text", typeof(string), typeof(LoadingDialog), new PropertyMetadata(0));
private void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
{
}
private void ContentDialog_SecondaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
{
}
}
And now you could use DialogService
to show the dialog proper.
private async void MainPage_Loaded(object sender, RoutedEventArgs e)
{
await dialogService.ShowLoadingDialogAsync();
await Task.Delay(3000);
await dialogService.HideLoadingDialogAsync();
}
Update
The other guess is the loading process is very quick that cause dialog disappears before it can be displayed. So you try to add task delay manually after
await BalanceViewModel.UpdateBalanceCommand.ExecuteAsync();
line
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…