Click or drag to resize

ObjectToDisplayNameConverter Class

Takes an object and returns the display name taken from it's DisplayNameAttribute
Inheritance Hierarchy
SystemObject
  TomsToolbox.Wpf.ConvertersValueConverter
    TomsToolbox.Wpf.ConvertersObjectToAttributeConverterDisplayNameAttribute
      TomsToolbox.Wpf.ConvertersObjectToDisplayNameConverter

Namespace:  TomsToolbox.Wpf.Converters
Assembly:  TomsToolbox.Wpf (in TomsToolbox.Wpf.dll) Version: 1.0.64.0 (1.0.64.0)
Syntax
[ValueConversionAttribute(typeof(Object), typeof(string))]
public class ObjectToDisplayNameConverter : ObjectToAttributeConverter<DisplayNameAttribute>

The ObjectToDisplayNameConverter type exposes the following members.

Constructors
  NameDescription
Public methodObjectToDisplayNameConverter
Initializes a new instance of the ObjectToDisplayNameConverter class
Top
Properties
  NameDescription
Public propertyConvertBackErrorValue
Gets or sets the error value, which is returned whenever the value to convert back produces an error; the default is UnsetValue.
(Inherited from ValueConverter.)
Public propertyConvertBackNullValue
Gets or sets the null value, which is returned whenever the value to convert back is null; the default is null.
(Inherited from ValueConverter.)
Public propertyConvertBackUnsetValue
Gets or sets the unset value, which is returned whenever the value to convert back is UnsetValue; the default is UnsetValue.
(Inherited from ValueConverter.)
Public propertyConvertErrorValue
Gets or sets the error value, which is returned whenever the value to convert produces an error; the default is UnsetValue.
(Inherited from ValueConverter.)
Public propertyConvertNullValue
Gets or sets the null value, which is returned whenever the value to convert is null; the default is null.
(Inherited from ValueConverter.)
Public propertyConvertUnsetValue
Gets or sets the unset value, which is returned whenever the value to convert is UnsetValue; the default is UnsetValue.
(Inherited from ValueConverter.)
Top
Methods
Fields
  NameDescription
Public fieldStatic memberDefault
The singleton instance of the converter.
Top
Extension Methods
Remarks
Works with any object; for enum types the attribute of the field is returned.
Examples
C#
enum Items
{
    [DisplayName("This is item 1")]
    Item1,
    [DisplayName("This is item 2")]
    Item2
}

Assert.Equals("This is item 1", ObjectToDisplayNameConverter.Convert(Items.Item1));
See Also