First take a user control as below,
public sealed partial class LoadingProcess : UserControl
{
public LoadingProcess()
{
this.InitializeComponent();
this.LayoutRoot.Height = Math.Ceiling(Window.Current.Bounds.Height);
this.LayoutRoot.Width = Math.Ceiling(Window.Current.Bounds.Width);
}
}And for that user control Xaml code will be like this,
<Grid x:Name="LayoutRoot" Background="Black" Opacity=".5" >
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<StackPanel Grid.Row="1" VerticalAlignment="Center" >
<ProgressBar IsIndeterminate="True" Foreground="White" Height="30" VerticalAlignment="Center"/>
<TextBlock Text="Please wait" Foreground="White" FontSize="20" HorizontalAlignment="Center"/>
</StackPanel>
</Grid>And add this user control as popup for class,class ScreenProcessbar
{
private Popup popup = new Popup();
public ScreenProcessbar()
{
}
public void loaderstart()
{
if (!popup.IsOpen)
{
LoadingProcess ovr = new LoadingProcess();
this.popup.Child = ovr;
this.popup.IsOpen = true;
}
}
public void loaderstop()
{
if (popup.IsOpen)
popup.IsOpen = false;
}
} And add this popup for any page to show progress bar as below by creating an object, var progressBar = new ScreenProcessbar();
progressBar.loaderstart();After completion of your async,await function just call this method to close the progress bar popup.
progressBar.loaderstop();Now you can add this popup for any page easily. And it will be fit for any device/resolution.Happy coding...:) .
