FlagEnumEditor
RadPropertyGrid now supports editing bit flag enum by exposing a new editor – FlagEnumEditor. It enables the user to store any combination of the values that are defined in the enumerator list:
You can define flag enum by setting FlagsAttribute as follows:
Defining flag enum
Each element should contain name and a value (which should be degree of 2 – 1, 2, 4, 8, 16, etc.).
You can find more information about enum and flag enum in this article.
Once you define your flag enum, you can edit it in RadPropertyGrid as follows:
Furthermore, if you define zero and -1 values in your flag enum (meaning no flags are set and all flags are set correspondingly), you can benefit from the built-in functionality for selecting and unselecting the elements of the enum:
Defining the flag enum
Do not define values with 0 and -1 values if you do not mean to use them as select no flag and select all flags.
You can manually define your FlagEnumEditor in XAML, like so:
Defining the FlagEnumEditor
Thus the FlagEnumEditor will look like this:
Display and Description Attributes
As of R2 2022 SP1, the FlagEnumEditor
control supports the Display
and Description
attributes which let you specify user-friendly and/or localizable strings for the enum values used in the user interface.
Using the Display and Description attributes
The
Display
attribute takes precedence over theDescription
attribute.