This documentation is archived and is not being maintained.

IMultiValueConverter.ConvertBack Method

Converts a binding target value to the source binding values.

Namespace:  System.Windows.Data
Assembly:  PresentationFramework (in PresentationFramework.dll)

abstract ConvertBack : 
        value:Object * 
        targetTypes:Type[] * 
        parameter:Object * 
        culture:CultureInfo -> Object[] 


Type: System.Object
The value that the binding target produces.
Type: System.Type[]
The array of types to convert to. The array length indicates the number and types of values that are suggested for the method to return.
Type: System.Object
The converter parameter to use.
Type: System.Globalization.CultureInfo
The culture to use in the converter.

Return Value

Type: System.Object[]
An array of values that have been converted from the target value back to the source values.

If there are more return values than there are bindings in the MultiBinding, the excess return values are ignored. If there are more source bindings than there are return values, the remaining source bindings do not have any values set on them. Types of return values are not verified against targetTypes; the values are set on the source bindings directly.

Return DoNothing at position i to indicate that no value is to be set on the source binding at index i.

Return DependencyProperty.UnsetValue at position i to indicate that the converter is unable to provide a value for the source binding at index i, and that no value is to be set on it.

Return a null reference (Nothing in Visual Basic) to indicate that the converter cannot perform the conversion or that it does not support conversion in this direction.

The data binding engine does not catch exceptions that are thrown by a user-supplied converter. Any exception that is thrown by the ConvertBack method or any uncaught exceptions that are thrown by methods that the ConvertBack method calls are treated as run-time errors. Handle anticipated problems by returning a null reference (Nothing in Visual Basic).

MultiBinding allows you to bind a binding target property to a list of source properties and then apply logic to produce a value with the given inputs. This example demonstrates how to use MultiBinding.

In the following example, NameListData refers to a collection of PersonName objects, which are objects that contain two properties, firstName and lastName. The following example produces a TextBlock that shows the first and last names of a person with the last name first.

  Title="MultiBinding Sample">
    <c:NameList x:Key="NameListData"/>
    <c:NameConverter x:Key="myNameConverter"/>




<TextBlock Name="textBox2" DataContext="{StaticResource NameListData}">
    <MultiBinding Converter="{StaticResource myNameConverter}"
      <Binding Path="FirstName"/>
      <Binding Path="LastName"/>



To understand how the last-name-first format is produced, let's take a look at the implementation of the NameConverter:

No code example is currently available or this language may not be supported.

NameConverter implements the IMultiValueConverter interface. NameConverter takes the values from the individual bindings and stores them in the values object array. The order in which the Binding elements appear under the MultiBinding element is the order in which those values are stored in the array. The value of the ConverterParameter attribute is referenced by the parameter argument of the Converter method, which performs a switch on the parameter to determine how to format the name.

.NET Framework

Supported in: 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.