Click or drag to resize

ObjectToTextConverter Class

Takes an object and returns the text taken from it's TextAttribute
Inheritance Hierarchy
SystemObject
  System.Windows.MarkupMarkupExtension
    TomsToolbox.Wpf.ConvertersValueConverter
      TomsToolbox.Wpf.ConvertersObjectToAttributeConverterTextAttribute
        TomsToolbox.Wpf.ConvertersObjectToTextConverter

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

The ObjectToTextConverter type exposes the following members.

Constructors
  NameDescription
Public methodObjectToTextConverter
Initializes a new instance of the ObjectToTextConverter 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.)
Public propertyKey
Gets or sets the key used to select the TextAttribute The converter parameter can override this value.
Top
Methods
  NameDescription
Public methodStatic memberConvert(Object, Object)
Converts the specified value to the text taken from it's TextAttribute
Public methodStatic memberConvert(Object, Object, Type)
Converts the specified value to the text taken from it's TextAttribute
Protected methodConvert(Object, Type, Object, CultureInfo)
Converts a value.
(Overrides ObjectToAttributeConverterTConvert(Object, Type, Object, CultureInfo).)
Protected methodConvertBack
Converts a value.
(Inherited from ValueConverter.)
Public methodProvideValue
When implemented in a derived class, returns an object that is provided as the value of the target property for this markup extension.
(Inherited from ValueConverter.)
Top
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. When used via the IValueConverter interface, the key is specified as the converter parameter.
Examples
enum Items
{
    [Text("key2", "This is other text on item 1")]
    [Text("key1", "This is item 1")]
    Item1,
    [Text("key1", "This is item 2")]
    Item2
}

Assert.Equal("This is item 1", ObjectToTextConverter.Convert("key1", Items.Item1));
See Also