The DispatcherService is an IDispatcherService implementation that allows you to perform actions in a ViewModel using the Dispatcher.

Getting Started with DispatcherService

Use the DispatcherService to perform an action in a ViewModel using the Dispatcher. Add the service to the view’s dxmvvmi:Interaction.Behaviors.

    xmlns:ViewModel="using:WinUIApp.ViewModel" ...>
        <ViewModel:ViewModel />
        <dxmvvm:DispatcherService />

Use the BeginInvoke method to perform the required actions. The example below uses the DispatcherService to execute the CalcCore method defined in the View Model.

public class ViewModel {
    protected IDispatcherService DispatcherService { get { return this.GetService<IDispatcherService>(); } }
    void CalcCore() {
        DispatcherService.BeginInvoke(() => { ... });

The DispatcherService has the following properties:

  • DispatcherPriority - gets or sets the DispatcherService’s Dispatcher priority by which operations can be invoked by the Dispatcher.
  • Delay - gets or sets the time delay (a TimeSpan object) before invoking the DispatcherService’s BeginInvoke method.