namespace XFEExtension.NetCore.WinUIHelper.Utilities.Additions; /// /// Provides an attached property for specifying the required permission level on UI elements. /// /// The PermissionAddition class enables developers to associate a required permission value with any /// UIElement using the RequiredPermission attached property. This can be used to control access or visibility of UI /// elements based on user permissions in WPF applications. public class PermissionAddition { /// /// Retrieves the required permission level associated with the specified UI element. /// /// The UI element from which to obtain the required permission level. Must not be null. /// An integer representing the required permission level for the specified UI element. public static int GetRequiredPermission(UIElement item) => (int)item.GetValue(RequiredPermissionProperty); /// /// Sets the required permission value for the specified UI element. /// /// This method attaches a permission value to the UI element using the RequiredPermission /// attached property. Use this to control access or visibility based on permission levels in your /// application. /// The UI element on which to set the required permission. Cannot be null. /// The permission value to assign to the UI element. public static void SetRequiredPermission(UIElement item, int value) => item.SetValue(RequiredPermissionProperty, value); /// /// Identifies the RequiredPermission attached dependency property, which specifies the required permission level /// for a UI element. /// /// This property can be attached to any DependencyObject to indicate the minimum permission /// level necessary for interaction or visibility. It is typically used in scenarios where UI elements should be /// enabled, visible, or accessible only to users with sufficient permissions. The default value is 0, representing /// no required permission. public static readonly DependencyProperty RequiredPermissionProperty = DependencyProperty.RegisterAttached("RequiredPermission", typeof(int), typeof(PermissionAddition), new PropertyMetadata(0)); }