In This Article

EnumBarGalleryItemViewModel<TEnum> Class

Represents a view model for a gallery item whose value and label based on the value in an enumeration.

public class EnumBarGalleryItemViewModel<TEnum> : BarGalleryItemViewModel<TEnum>, IBarGalleryItemViewModel, IEquatable<IBarGalleryItemViewModel> where TEnum : struct, IComparable, IFormattable
Type Parameters:
TEnum -

The enumeration type of the value associated with this gallery item.

Inheritance:
object ObservableObjectBase BarGalleryItemViewModel<TEnum> object
Implements:
IBarGalleryItemViewModel IEquatable<IBarGalleryItemViewModel>

Constructors

EnumBarGalleryItemViewModel()

Initializes a new instance of the class.

public EnumBarGalleryItemViewModel()

EnumBarGalleryItemViewModel(TEnum)

Initializes a new instance of the class with the specified value.

public EnumBarGalleryItemViewModel(TEnum value)
Parameter Type Description
value TEnum

The item's value.

EnumBarGalleryItemViewModel(TEnum, string)

Initializes a new instance of the class with the specified value and category.

public EnumBarGalleryItemViewModel(TEnum value, string category)
Parameter Type Description
value TEnum

The item's value.

category string

The item's category, or null if categorization is not supported.

EnumBarGalleryItemViewModel(TEnum, string, string)

Initializes a new instance of the class with the specified value, category, and label.

public EnumBarGalleryItemViewModel(TEnum value, string category, string label)
Parameter Type Description
value TEnum

The item's value.

category string

The item's category, or null if categorization is not supported.

label string

The text label to display, or null if the label can be coerced from the current value.

Properties

IsLabelVisible

Gets whether the Label is visible.

public override bool IsLabelVisible { get; }

Property Value

bool:

true if the Label is visible; otherwise, false.

Order

Gets or sets the sort order for this item, where lower values appear before higher values.

public int Order { get; set; }

Property Value

int:

An integer value.

Methods

CreateCollection()

Creates a collection of gallery item view models representing the values defined for an enumeration type.

public static IEnumerable<EnumBarGalleryItemViewModel<TEnum>> CreateCollection()

Returns

IEnumerable<EnumBarGalleryItemViewModel<TEnum>>:

The collection of gallery item view models that was created.

Exceptions

Type Condition
InvalidOperationException

RefreshFromAttributes()

Refreshes supported properties based the attributes, if any, defined on the enumeration field associated with this view model's value. Properties are only updated if a non-null value is obtained from the corresponding attribute. Otherwise, existing property values are unchanged.

public void RefreshFromAttributes()

Remarks

Call this method after any changes in locale since DisplayAttribute supports localization and is used to populate several properties on this view model.

Fields

DefaultOrder

Gets the default sort order for enumeration items that do not define an order using the Order property.

public const int DefaultOrder = 10000

Inherited Members