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>
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>

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

Gets or sets the item's category.

public string Category { get; set; }

Property Value

string:

The item's category.

Description

Gets or sets the text description to display in screen tips.

public string Description { get; set; }

Property Value

string:

The text description to display in screen tips.

ImageSource

Gets or sets the image to display, if the item's template supports an image.

public ImageSource ImageSource { get; set; }

Property Value

ImageSource:

An ImageSource for the image.

IsLabelVisible

Gets whether the Label is visible.

public virtual bool IsLabelVisible { get; }

Property Value

bool:

true if the Label is visible; otherwise, false.

KeyTipText

Gets or sets the key tip text used to access the control.

public string KeyTipText { get; set; }

Property Value

string:

The key tip text used to access the control.

Label

Gets or sets the text label to display.

public string Label { get; set; }

Property Value

string:

The text label to display.

Remarks

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

LayoutBehavior

Gets or sets a BarGalleryItemLayoutBehavior indicating how the gallery item should be visually displayed.

public BarGalleryItemLayoutBehavior LayoutBehavior { get; set; }

Property Value

BarGalleryItemLayoutBehavior:

A BarGalleryItemLayoutBehavior indicating how the gallery item should be visually displayed. The default value is Default.

Value

Gets or sets the value associated with this view model.

public virtual TValue Value { get; set; }

Property Value

TValue:

An object of type 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 : struct, IComparable, IFormattable
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