How to: Manually Invoke DXSplashScreen

  • 4 minutes to read
NOTE

You are viewing documentation for the legacy DXSplashScreen. We recommend that you use the Splash Screen Manager or the SplashScreenManagerService to add the splash screen functionality to your applications.

After DXSplashScreen has been added to your project, you need to invoke it on the application startup. It can be invoked either automatically or manually.

Invoking DXSplashScreen Manually

You can also manually control when to display and hide DXSplashScreen. This can be accomplished by calling static methods provided by the DXSplashScreen class.

For instance, the following code opens a splash screen on the application startup.

using DevExpress.Xpf.Core;

namespace WpfApplication1 {
    public partial class App : Application {
        protected override void OnStartup(StartupEventArgs e) {
            base.OnStartup(e);
            DXSplashScreen.Show<SplashScreenView1>();
        }
    }
}

The following code closes the opened splash screen when the main window is initialized.

using DevExpress.Xpf.Core;

namespace WpfApplication1 {
    public partial class MainWindow : Window {
        public MainWindow() {
            InitializeComponent();
            this.Loaded += new RoutedEventHandler(MainWindow_Loaded);
        }

        void MainWindow_Loaded(object sender, RoutedEventArgs e) {
            DXSplashScreen.Close();
            this.Activate();
        }
    }
}

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.

<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>
See Also