Issue with behavior of pinning apps to the taskbar on Windows 10

Kostas Pathiakis 1 Reputation point

Hey all,

There is some weird behavior I have noticed when pinning/unpinning a WPF app to the taskbar:

  1. I run the app, right-click on its taskbar icon and select to pin it to the taskbar.
  2. I then right-click on the same icon and select to unpin it from the taskbar.
  3. Right-click a third time and the app icon has now changed, the app name is missing from the context menu and selecting to pin it back to the taskbar does not seem to do anything.

Is this behavior really intended, or, if not, what is the proper way to correct and make it more consistent?

This behavior can be very easily replicated by creating and running a brand new WPF app in Visual Studio, using the relevant project template.

I'm using .net6, VisualStudio 2022 on WIndows 10.

Thank you in advance,

EDIT: The icon does not seem to break every time, but the context menu does.

Windows 10
Windows 10
A Microsoft operating system that runs on personal computers and tablets.
9,480 questions
Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,553 questions
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
9,461 questions
{count} votes

2 answers

Sort by: Most helpful
  1. S.Sengupta 13,446 Reputation points MVP

    Rebuild Icon Cache.

    Open Command Prompt as Administrator.

    In Command Prompt, input the commands below one by one and press Enter after each:

    cd /d %userprofile%\AppData\Local\Microsoft\Windows\Explorer
    attrib –h iconcache_.db
    del iconcache_
    .db start explorer


  2. Lex Li (Microsoft) 4,031 Reputation points

    Cannot reproduce this on Windows 11 (22000.1098) with .NET 6 or .NET 7 RC based WPF.

    You might need more environments to reveal what exactly was the cause, but I doubt it is due to .NET Core (6/7) itself.