Built-in Progress Bar
- 4 minutes to read
Built-in Progress Bar
A default splash screen contains a marquee progress bar, which continuously changes its progress. When you manually display/close DXSplashScreen, you can set its display mode to regular where the progress changes between 0 and 100. To change a display mode to regular and to step through progress, use the static DXSplashScreen.Progress(double value) method.
for(int i = 0; i <= 100; i++) {
DXSplashScreen.Progress(i);
//...
}
You can use the DXSplashScreen.SetState method to pass custom information to a splash screen. The example below demonstrates how to use this method.
Example
This example shows how to manually invoke and close DXSplashScreen.By default, DXSplashScreen contains a progress bar, indicating the progress of the application load. This example also shows how you can manually change the progress in code.
Note
A complete sample project is available at https://github.com/DevExpress-Examples/how-to-manually-invoke-and-close-dxsplashscreen-e3243.
<UserControl x:Class="DXSplashScreenSample.SplashScreenView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
mc:Ignorable="d"
d:DataContext="{x:Static dx:SplashScreenViewModel.DesignTimeData}"
>
<Grid x:Name="LayoutRoot">
<Grid x:Name="Splash" Width="450" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="0">
<Grid x:Name="Back">
<Border Background="Black" CornerRadius="3" Opacity="0.15"/>
<Border CornerRadius="2" Margin="1" Background="White"/>
</Grid>
<Grid x:Name="Content_Area" Margin="12">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Image x:Name="Image" Source="Image.png" Stretch="None"/>
<TextBlock x:Name="Info" TextWrapping="Wrap" Text="{Binding State}" Grid.Row="1" Margin="12,12,12,0" Foreground="#FF2D2D2D"/>
<ProgressBar x:Name="progressBar"
Height="12"
Grid.Row="2"
Margin="12"
IsIndeterminate="{Binding IsIndeterminate}"
Value="{Binding Progress}"
Maximum="{Binding MaxProgress}"/>
<DockPanel x:Name="Footer" Grid.Row="3" Margin="12,20,12,4">
<TextBlock x:Name="Footer_Text" TextWrapping="Wrap" Text="Copyright © 1998-2015" Opacity="0.5" Foreground="#FF2D2D2D" HorizontalAlignment="Left" VerticalAlignment="Center"/>
<Image x:Name="Logotype" DockPanel.Dock="Right" Source="Logo.png" Stretch="None" HorizontalAlignment="Right" />
</DockPanel>
</Grid>
</Grid>
</Grid>
</UserControl>