In This Article

BarGalleryItemViewModel<TValue> Class

Represents a view model for a gallery item within a bar gallery control.

public class BarGalleryItemViewModel<TValue> : ObservableObjectBase, IBarGalleryItemViewModel, IEquatable<IBarGalleryItemViewModel>, IHasTag
Type Parameters:
TValue -

The type of the value associated with this gallery item.

Inheritance:
object ObservableObjectBase object
Derived:
ColorBarGalleryItemViewModel EnumBarGalleryItemViewModel<TEnum> FontFamilyBarGalleryItemViewModel FontSizeBarGalleryItemViewModel SymbolBarGalleryItemViewModel TextBarGalleryItemViewModel TextStyleBarGalleryItemViewModel
Implements:
IBarGalleryItemViewModel IEquatable<IBarGalleryItemViewModel> IHasTag

Constructors

BarGalleryItemViewModel()

Initializes a new instance of the class.

protected BarGalleryItemViewModel()

BarGalleryItemViewModel(TValue?)

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

protected BarGalleryItemViewModel(TValue? value)
Parameter Type Description
value TValue

The item's value.

BarGalleryItemViewModel(TValue?, string?)

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

protected BarGalleryItemViewModel(TValue? value, string? category)
Parameter Type Description
value TValue

The item's value.

category string

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

BarGalleryItemViewModel(TValue?, string?, string?)

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

protected BarGalleryItemViewModel(TValue? value, string? category, string? label)
Parameter Type Description
value TValue

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

Category

The item's category.

public string? Category { get; set; }

Property Value

string

Description

The text description to display in screen tips.

public string? Description { get; set; }

Property Value

string

Icon

The value representing the icon to display, if the item's template supports an icon.

public object? Icon { get; set; }

Property Value

object

IsLabelVisible

Indicates whether the Label is visible.

public virtual bool IsLabelVisible { get; }

Property Value

bool

IsVisible

Indicates whether the control is currently visible.

public bool IsVisible { get; set; }

Property Value

bool:

The default value is true.

KeyTipText

The key tip text used to access the control.

public string? KeyTipText { get; set; }

Property Value

string

Label

The text label to display.

public string? Label { get; set; }

Property Value

string

Remarks

If the label is not explicitly defined, the value may be coerced.

LayoutBehavior

A BarGalleryItemLayoutBehavior indicating how the gallery item should be visually displayed.

public BarGalleryItemLayoutBehavior LayoutBehavior { get; set; }

Property Value

BarGalleryItemLayoutBehavior:

The default value is Default.

Tag

A user-defined object attached to the control.

public object? Tag { get; set; }

Property Value

object

Value

The value associated with this view model.

public virtual TValue? Value { get; set; }

Property Value

TValue

Methods

CoerceLabel()

Gets the coerced value to use as the Label when an explicit value has not been defined.

protected virtual string? CoerceLabel()

Returns

string:

The coerced text label to display.

See Also

ConvertEnumValueToString(Type, object?, bool)

Converts the specified enumeration value to a string representation.

protected static string? ConvertEnumValueToString(Type enumType, object? enumValue, bool useAttributes)
Parameter Type Description
enumType Type

The enumeration Type to examine.

enumValue object

The enumeration value.

useAttributes bool

Whether to use description or display attributes.

Returns

string:

A string representation of the specified value or null if the value and/or type is not recognized as an enumeration.

ConvertEnumValueToString<TEnum>(TEnum, bool)

Converts the specified enumeration value to a string representation.

protected static string? ConvertEnumValueToString<TEnum>(TEnum enumValue, bool useAttributes) where TEnum : Enum
Type Parameters:
TEnum -

The type of the enumeration.

Parameter Type Description
enumValue TEnum

The enumeration value.

useAttributes bool

Whether to use description or display attributes.

Returns

string:

A string representation of the specified value or null if the value type is not an enumeration.

Equals(IBarGalleryItemViewModel?)

Indicates whether the current object is equal to another object of the same type.

public virtual bool Equals(IBarGalleryItemViewModel? other)
Parameter Type Description
other IBarGalleryItemViewModel

An object to compare with this object.

Returns

bool:

true if the current object is equal to the other parameter; otherwise, false.

Equals(object?)

Determines whether the specified object is equal to the current object.

public override sealed bool Equals(object? obj)
Parameter Type Description
obj object

The object to compare with the current object.

Returns

bool:

true if the specified object is equal to the current object; otherwise, false.

GetHashCode()

Serves as the default hash function.

public override int GetHashCode()

Returns

int:

A hash code for the current object.

OnValueChanged()

Raises the PropertyChanged event for the Value property and any other properties that are dependent on the value.

protected virtual void OnValueChanged()

ToString()

Returns the string representation of this object.

public override string ToString()

Returns

string:

The string representation of this object.

Inherited Members

Extension Methods