How to show a UAC shield icon in WPF and Windows Forms/WinForms in C# and VB
|A User Account Control prompt in Windows Vista|
|UAC shield icons in Windows 11 Control Panel|
As a WPF (Windows Presentation Foundation) and/or Windows Forms developer, you might want to add this shield icon to your UI to controls whose default action requires elevation. Windows Forms provides this icon in the System.Drawing.SystemIcons.Shield and the documentation recommends using it for this scenario. This icon can also be accessed in WPF.
How to access the UAC shield icon in WPF
|WPF UAC Button|
How to access the UAC shield icon in Windows Forms
This should result in a Button that looks something like this:
Why is the Windows Vista UAC shield icon being used?Unfortunately, Microsoft is yet to update the System.Drawing.SystemIcons.Shield to use newer versions of the icon on newer operating systems. Have a look at the issue here for more information.
Did this guide help you? Do you have anything to add? Let us know in the comments! Also, if this guide did help you and you use an AdBlocker and you want to support us, consider disabling it for this site - if you do, it will be greatly appreciated!