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, INotifyPropertyChanged, IEquatable<IBarGalleryItemViewModel>
Type Parameters:
TValue -

The type of the value associated with this gallery item.

Inheritance:
System.Object ObservableObjectBase Object
Derived:
ColorBarGalleryItemViewModel EnumBarGalleryItemViewModel<TEnum> FontFamilyBarGalleryItemViewModel FontSizeBarGalleryItemViewModel SymbolBarGalleryItemViewModel TextBarGalleryItemViewModel TextStyleBarGalleryItemViewModel
Implements:
IBarGalleryItemViewModel System.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 System.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 System.String

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

label System.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

System.String:

The item's category.

Description

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

public string Description { get; set; }

Property Value

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

System.Windows.Media.ImageSource:

An System.Windows.Media.ImageSource for the image.

IsLabelVisible

Gets whether the Label is visible.

public virtual bool IsLabelVisible { get; }

Property Value

System.Boolean:

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

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

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

System.String:

The coerced text label to display.

See Also

ConvertEnumValueToString(Type, Object, Boolean)

Converts the specified enumeration value to a string representation.

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

The enumeration System.Type to examine.

enumValue System.Object

The enumeration value.

useAttributes System.Boolean

Whether to use description or display attributes.

Returns

System.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, Boolean)

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 System.Boolean

Whether to use description or display attributes.

Returns

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

System.Boolean:

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 System.Object

The object to compare with the current object.

Returns

System.Boolean:

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

System.Int32:

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 a string that represents the current object.

public override string ToString()

Returns

System.String:

A string that represents the current object.

Explicit Interface Implementations

IBarGalleryItemViewModel.Value

Gets or sets the value associated with this view model.

object IBarGalleryItemViewModel.Value { get; set; }

Returns

System.Object:

An object.

Inherited Members