SplashScreenService Class
Allows you to display splash screens.
Namespace: DevExpress.Mvvm.UI
Assembly: DevExpress.UI.Xaml.v19.1.dll
Declaration
Remarks
You can use splash screens to provide an end-user with information about the progress of certain processes in your application.
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
Note
A complete sample project is available at: https://github.com/DevExpress-Examples/how-to-use-splashscreenservice-t418944
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();
}
}
}