Dan
Dan

Reputation: 149

Jumplists in VB.NET Windows Form Application

Is there a way to create Windows Taskbar jumplists in a VB.NET Windows Form Application? I'd like to add my last opened files to the list.

I've done a bunch of searching and can find this: https://learn.microsoft.com/en-us/dotnet/api/system.windows.shell.jumplist?redirectedfrom=MSDN&view=net-5.0, but I can't figure out how to get System.Windows.Shell to be accessible in my application. It says the namespace can't be found.

Any direction you can point me would be appreciated!

Upvotes: 1

Views: 468

Answers (1)

Dan
Dan

Reputation: 149

Here's what I got working:

Dim a As System.Windows.Application = System.Windows.Application.Current
If a Is Nothing Then a = New System.Windows.Application

Dim currJumpList As System.Windows.Shell.JumpList = JumpList.GetJumpList(a)
If currJumpList Is Nothing Then
    currJumpList = New JumpList
    JumpList.SetJumpList(a, currJumpList)
Else
    currJumpList.JumpItems.Clear()
End If

Dim jumpTask As JumpTask

jumpTask = New JumpTask
jumpTask.Title = "This is what gets shown to the user"
jumpTask.Description = "This is what the user sees if they hover or the item"
jumpTask.ApplicationPath = "pathToYourEXE"
jumpTask.Arguments = "Your arguments"
jumpTask.CustomCategory = "The category header"
currJumpList.JumpItems.Add(jumpTask)

currJumpList.Apply()

Important Notes:

  • You'll need to add a reference to PresentationFramework.dll. If your in Visual Studio, its in the Framework section.
  • its really important to call the Apply() after you make changes to the JumpList.
  • if you are winforms, the moment you add a reference to you PresentationFramework, you'll notice the appearance of your GUI changes. This appears to be releated to DPI awareness. To fix, Go to your Project Properties --> Application --> View Windows Settings. This should bring up your app.manifest. In there, you'll see a commented section on dpiaware. Uncomment the entire section. Play with setting the value to true / false. I found that false would keep the GUI looking like it used to, while true improved the clarity of the fonts in my GUI. Either value should fix the issue though.

Upvotes: 2

Related Questions