Skip to content

net472_PropertyGridHelpers.Attributes_ResourcePathAttribute

dparvin edited this page Jan 11, 2026 · 14 revisions

ResourcePathAttribute class

Specifies the location of a resource type (e.g., strings, images, cursors) to be used in conjunction with UI editors, type converters, or design-time attributes.

[AttributeUsage(AttributeTargets.Class | AttributeTargets.Enum | AttributeTargets.Property, 
    AllowMultiple = true)]
public class ResourcePathAttribute : Attribute

Public Members

name description
ResourcePathAttribute(…) Initializes a new instance of the ResourcePathAttribute class, specifying the path, optional assembly name, and usage.
static Get(…) Resolves the most appropriate ResourcePathAttribute for the given context and usage.
ResourceAssembly { get; } Gets the resource assembly.
ResourcePath { get; } Gets the resource path associated with the property or enum value.
ResourceUsage { get; } Gets the intended usage for the resource path (e.g., Strings or Images). Used to filter multiple attributes for different purposes.
GetAssembly() Resolves the assembly object from the stored assembly name.

Remarks

This attribute can be applied to properties, enum types, or classes to associate them with a strongly-typed resource class (e.g., Properties.Resources). The optional ResourceUsage flag allows specifying what the path is used for, enabling separation of string resources, image resources, and more. If multiple ResourcePathAttributes are applied, the resolution order is:

  1. Property-level attributes
  2. Enum type or property type-level attributes
  3. Class-level attributes (declaring type)

Examples

Example 1: Use for enum text

[ResourcePath("MyNamespace.MyEnumResources", resourceUsage: ResourceUsage.Strings)]
public enum ButtonType
{
    [EnumText("Primary")]
    Primary,
    [EnumText("Secondary")]
    Secondary
}

Example 2: Separate image path for UI editor

[ResourcePath("MyNamespace.ButtonImages", resourceUsage: ResourceUsage.Images)]
public enum ButtonType { ... }

See Also

Clone this wiki locally