Muokkaa

Jaa


IValueConverter Interface

Definition

Provides a way to apply custom logic to a binding.

public interface class IValueConverter
public interface IValueConverter
type IValueConverter = interface
Public Interface IValueConverter
Derived

Remarks

If you want to associate a value converter with a binding, create a class that implements the IValueConverter interface and then implement the Convert and ConvertBack methods. Converters can change data from one type to another, translate data based on cultural information, or modify other aspects of the presentation. For examples of some typical converter scenarios, see "Data Conversion" in Data Binding Overview.

Value converters are culture-aware. Both the Convert and ConvertBack methods have a culture parameter that indicates the cultural information. If cultural information is irrelevant to the conversion, then you can ignore that parameter in your custom converter.

The Convert and ConvertBack methods also have a parameter called parameter so that you can use the same instance of the converter with different parameters. For example, you can write a formatting converter that produces different formats of data based on the input parameter that you use. You can use the ConverterParameter of the Binding class to pass a parameter as an argument into the Convert and ConvertBack methods.

Methods

Convert(Object, Type, Object, CultureInfo)

Converts a value.

ConvertBack(Object, Type, Object, CultureInfo)

Converts a value.

Applies to

See also