Skip to main content
A newer version of this page is available. .

SplashScreenService Class

Allows you to display splash screens.

Namespace: DevExpress.Mvvm.UI

Assembly: DevExpress.UI.Xaml.v19.1.dll

Declaration

public class SplashScreenService :
    ViewServiceBase,
    ISplashScreenService

Remarks

You can use splash screens to provide an end-user with information about the progress of certain processes in your application.

SplashScreenGif

To add a splash screen to the application, define the SplashScreenService in the Interaction.Behaviors collection.

xmlns:dxmvvmui="using:DevExpress.Mvvm.UI"
xmlns:dxmvvmi="using:DevExpress.Mvvm.UI.Interactivity"

<dxmvvmi:Interaction.Behaviors>
    <dxmvvmui:SplashScreenService />    
</dxmvvmi:Interaction.Behaviors>

Then, access the attached SplashScreenService in your ViewModel by using the ViewModelBase.GetService method and invoke the ISplashScreenService.ShowSplashScreen method to show the splash screen.

public class MainViewModel : ViewModelBase {

    public ICommand ShowSplashScreenCommand { get; private set; }

    public ISplashScreenService DefaultSplashScreenService {
        get {
            return this.GetService<ISplashScreenService>();
        }
    }

    public MainViewModel() {
        ShowSplashScreenCommand = new DelegateCommand(OnShowSplashScreenCommandExecute);        
    }

    private async void OnShowSplashScreenCommandExecute() {
        DefaultSplashScreenService.ShowSplashScreen();
        await Task.Delay(4000);
        DefaultSplashScreenService.HideSplashScreen();
    }
}

Use the SplashScreenService.SplashScreenType property to specify the type of view containing a splash screen that needs to be shown.

Important

SplashScreenService works only when the DXFrame or HamburgerMenuFrame is used.

Example

using DevExpress.Mvvm;
using System.Threading.Tasks;
using System.Windows.Input;

namespace App1 {
    public class MainViewModel : ViewModelBase {

        public ICommand ShowSplashScreenCommand { get; private set; }
        public ICommand ShowProgressBarSplashScreenCommand { get; private set; }
        public ISplashScreenService DefaultSplashScreenService {
            get {
                return this.GetService<ISplashScreenService>("DefaultSplashScreen");
            }
        }
        public ISplashScreenService ProgressBarSplashScreenService {
            get {
                return this.GetService<ISplashScreenService>("ProgressBarSplashScreen");
            }
        }

        public MainViewModel() {
            ShowSplashScreenCommand = new DelegateCommand(OnShowSplashScreenCommandExecute);
            ShowProgressBarSplashScreenCommand = new DelegateCommand(OnShowProgressBarSplashScreenCommandExecute);
        }

        private async void OnShowSplashScreenCommandExecute() {
            DefaultSplashScreenService.ShowSplashScreen();
            await Task.Delay(4000);
            DefaultSplashScreenService.HideSplashScreen();
        }

        private async void OnShowProgressBarSplashScreenCommandExecute() {
            ProgressBarSplashScreenService.ShowSplashScreen();

            ProgressBarSplashScreenService.SetSplashScreenState("Loading...");
            ProgressBarSplashScreenService.SetSplashScreenProgress(20, 100);
            await Task.Delay(2000);
            ProgressBarSplashScreenService.SetSplashScreenState("Initializing...");
            ProgressBarSplashScreenService.SetSplashScreenProgress(80, 100);
            await Task.Delay(2000);
            ProgressBarSplashScreenService.SetSplashScreenState("Finishing...");
            ProgressBarSplashScreenService.SetSplashScreenProgress(100, 100);
            await Task.Delay(2000);
            ProgressBarSplashScreenService.HideSplashScreen();
        }
    }
}

Inheritance

Object
DependencyObject
DevExpress.Mvvm.UI.Interactivity.AttachableObjectBase
DevExpress.Mvvm.UI.Interactivity.Behavior
DevExpress.Mvvm.UI.Interactivity.Behavior<FrameworkElement>
DevExpress.Mvvm.UI.ServiceBaseGeneric<FrameworkElement>
ServiceBase
ViewServiceBase
SplashScreenService
See Also