ApplicationJumpListService

  • 3 minutes to read

ApplicationJumpListService allows you to add your own items to the Window's Jump Lists in accordance with MVVM.
ApplicationJumpListService implements the IApplicationJumpListService interface.

ApplicationJumpTask01

Getting Started

To add custom items to the application's jump list, add the ApplicationJumpListService to the Interaction.Behaviors collection.

<dxmvvm:Interaction.Behaviors>
    <dxmvvm:ApplicationJumpListService>
        <dxmvvm:ApplicationJumpTask Title="Internet Explorer" CustomCategory="Internet" Description="Internet Explorer" Command="{Binding RunInternetExplorerCommand}" Icon="{dx:DXImageOffice2013 Image=ViewOnWeb_16x16.png}"/>
    </dxmvvm:ApplicationJumpListService>
</dxmvvm:Interaction.Behaviors>

The ApplicationJumpListService defined in the code snippet above adds a JumpTask, which invokes the View Mode's RunInternetExplorerCommand to the Internet category in the application's Jump Lists.

Here is View Model definition.

[POCOViewModel]
public class MainViewModel {
    protected IApplicationJumpListService ApplicationJumpListService { 
        get { return this.GetService<IApplicationJumpListService>(); } 
    }

    public void RunInternetExplorer() {
        Process.Start(@"C:\Program Files\Internet Explorer\iexplore.exe");
    }
}

The ApplicationJumpTask class implements the functionality of an individual jump task that can be displayed within the Jump List of the application's taskbar button.

The most straightforward way to add items to a jump list is to specify ApplicationJumpTask objects directly in XAML. Alternatively, you can use the AddOrReplace method overloads of the ApplicationJumpListService.Items collection to add a jump task in code-behind.

[POCOViewModel]
public class MainViewModel {
    protected IApplicationJumpListService ApplicationJumpListService { get { return this.GetService<IApplicationJumpListService>(); } }
    ...
    private void RunWindowsMediaPlayer() {
        Process.Start(@"C:\Program Files (x86)\Windows Media Player\wmplayer.exe");
    }
    public void AddItem() {
        ApplicationJumpListService.Items.AddOrReplace(
            "Media", 
            "Windows Media Player", 
            new BitmapImage(new Uri(@"pack://application:,,,/DevExpress.Images.v14.2;component/Office2013/Miscellaneous/Video_16x16.png", UriKind.Absolute)),
            () => RunWindowsMediaPlayer()
        );
        ApplicationJumpListService.Apply();
    }
}

Note that if you add jump tasks in code manually, you have to execute the ApplicationJumpListService.Apply method, so the application registers and adds the newly added jump tasks to its Jump List.

using DevExpress.Mvvm;
using DevExpress.Mvvm.POCO;
using DevExpress.Mvvm.DataAnnotations;
using System;
using System.Diagnostics;
using System.Windows.Media.Imaging;
using DevExpress.Xpf.Core;

namespace DXSampleApplicationJumpListService.ViewModel {
    [POCOViewModel]
    public class MainViewModel {
        protected IApplicationJumpListService ApplicationJumpListService { get { return this.GetService<IApplicationJumpListService>(); } }

        public void RunInternetExplorer() {
            Process.Start(@"C:\Program Files\Internet Explorer\iexplore.exe");
        }
        private void RunWindowsMediaPlayer() {
            Process.Start(@"C:\Program Files (x86)\Windows Media Player\wmplayer.exe");
        }
        public void AddItem() {
            ApplicationJumpListService.Items.AddOrReplace(
                "Media", 
                "Windows Media Player", 
             new BitmapImage(DXImageHelper.GetImageUri("Images/Miscellaneous/Video_16x16.png")),
                () => RunWindowsMediaPlayer()
            );
            ApplicationJumpListService.Apply();
        }
    }
}