0

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!

Dan
  • 89
  • 6
  • 1
    Do you have a reference to PresentationFramework.dll in your project? – Hursey Apr 26 '21 at 20:25
  • That page is for WPF/UWP so I'm not sure that it will work at all in WinForms. It's worth trying out but you may need to at least make significant changes. – jmcilhinney Apr 27 '21 at 00:33
  • [Microsoft-WindowsAPICodePack-Shell](https://www.nuget.org/packages/Microsoft-WindowsAPICodePack-Shell/) (target .Net Framework 4.8) – Jimi Apr 27 '21 at 01:47
  • I'm not sure if this is the right place to ask a follow up question. Please let me know if not. I as able to get this sort of working by adding the reference to PresentationFramework.dll. What's happening now is anytime I call things related to System.Windows.Application, the fonts of my gui look much smaller than normal. Is that a WPF vs Winforms thing? – Dan Apr 27 '21 at 16:31
  • Just made a blank winforms project. Anytime I add the reference to PresentationFramework.dll, the GUI looks totally different (smaller size/fonts). What's up with that? – Dan Apr 27 '21 at 16:44
  • 1
    Read the notes here: [DPI Awareness - Unaware in one Release, System Aware in the Other](https://stackoverflow.com/a/50276714/7444103). If you want to disable automatic the DpiAwarenes introduced by referencing `PresentationFramework` assemblies, skip to the last paragraph. -- I suggest to make your app DpiAware regardless. – Jimi Apr 27 '21 at 17:22

1 Answers1

1

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.
Dan
  • 89
  • 6