In the WPF program, if the entire program requires admin permission, we can set the app. manifest file to pop up UAC when the program starts, allowing the entire program to have admin permission,
However, in some cases, it is not necessary for the entire program to have admin permission, and only some buttons need to have admin permission.
The usual method is to add a "shield" icon to the button, and then pop up UAC. If there is no need to restart the current program at this time, how can the button have admin permission?
How to enhance the admin permission of buttons in WPF
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.

Tahir AnsariRank #366 · 6.8K reputationPosted Jul 25, 2023, 12:24 PM EDT
Please try the below
public bool IsAdminRole { get; set; } // In the constructor or after authentication if (userRole == "Admin") { IsAdminRole = true; } else { IsAdminRole = false; }public bool IsAdminRole { get; set; } // In the constructor or after authentication if (userRole == "Admin") { IsAdminRole = true; } else { IsAdminRole = false; }private void DeleteButton_Click(object sender, RoutedEventArgs e) { if (IsAdminRole) { // Perform delete action } else { MessageBox.Show("You don't have permission to perform this action."); } }