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

Kostas Pathiakis 1 Reputation point
2022-10-24T12:13:16.3+00:00

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.
    253524-pin1.jpg
  2. I then right-click on the same icon and select to unpin it from the taskbar.
    253410-pin2.jpg
  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.
    253504-pin3.jpg

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

Replication:
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,
Kostas

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.
11,840 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,798 questions
C#
C#
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.
11,114 questions
{count} votes

2 answers

Sort by: Most helpful
  1. S.Sengupta 20,636 Reputation points MVP
    2022-10-24T12:56:47.82+00:00

    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

    Reboot.


  2. Lex Li (Microsoft) 5,662 Reputation points Microsoft Employee
    2022-10-24T19:58:21.027+00:00

    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.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.