Export (0) Print
Expand All

MultiBinding.ConverterParameter Property

Gets or sets an optional parameter to pass to a converter as additional information.

Namespace: System.Windows.Data
Assembly: PresentationFramework (in presentationframework.dll)
XML Namespace:  http://schemas.microsoft.com/winfx/2006/xaml/presentation

public:
property Object^ ConverterParameter {
	Object^ get ();
	void set (Object^ value);
}
/** @property */
public Object get_ConverterParameter ()

/** @property */
public void set_ConverterParameter (Object value)

public function get ConverterParameter () : Object

public function set ConverterParameter (value : Object)

<object>
  <object.ConverterParameter>
    <converterParameter .../>
  </object.ConverterParameter>
</object>
<object property="converterParameter" />

Property Value

A parameter to pass to a converter. The default value is 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.

<Window
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:c="clr-namespace:SDKSample"
  x:Class="SDKSample.Window1"
  Width="400"
  Height="280"
  Title="MultiBinding Sample">
	
  <Window.Resources>
    <c:NameList x:Key="NameListData"/>
    <c:NameConverter x:Key="myNameConverter"/>

	...

  </Window.Resources>

	...

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

	...

</Window>

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.

For the complete sample, see Implementing Parameterized MultiBinding Sample.

For another example of an IMultiValueConverter implementation, see Data Binding Demo.

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0

Community Additions

ADD
Show:
© 2014 Microsoft