Click or drag to resize

MultiBinding

A MultiBinding accepts a collection and produces a final value based on expression and filters. Output can be either a collection or a result of collection aggregation.

Example
                  <
                  Field Id="Field_ClickedTubes" Value="{MultiBinding Source={Binding ItemId=Tube}, Filter=Conditional, FilterParameter=${Binding ClickCount, Converter=GreaterThan, ConverterParameter=0}}" />
Parameters
  • Path (default): string

    List of properties to access in order to obtain a target value, separated by dots. Can also contain the names to be used in lookups. Is used to get a value from each item of a source collection.

  • Expression: string

    Markup extension expression to be created for each item of a source collection. Must start with $ character, which signifies a string literal.

  • Source: IObservableCollection

    Source of the binding. Must be a collection of items.

  • Filter: IFilter

    Filter that can pass or discard items of a collection.

    Example
    {MultiBinding Source={Binding ItemId=Tube}, Filter={CompositeFilter F1=Conditional, P1=${Binding IsClickable}, F2=Skip, P2=3, F3=Take, P3=2}}

    Filter in example above selects all clickable tubes, skips first three and takes first two out of remaining.

    Allowed values:

    • Skip: IFilter

      Skips n item(s) from available items.

      Example
      {MultiBinding Source={Binding ItemId=Tube}, Filter={CompositeFilter F1=Skip, P1=2}}

      In the example above, the filter selects all tubes and skips the first two.

    • Take: IFilter

      Takes n item(s) from available items.

      Example
      {MultiBinding Source={Binding ItemId=Tube}, Filter={CompositeFilter F1=Take, P1=3}}

      In the example above, the filter selects all tubes and takes the first three.

    • Conditional: IFilter

      Selects item(s) from available items based on given condition(s).

      Example
      {MultiBinding Source={Binding ItemId=Tube}, Filter={CompositeFilter F1=Conditional, P1=${Binding IsClickable}}}

      In the example above, the filter selects all clickable tubes.

    • OrderBy: IFilter

      Sorts available items in ascending order.

      Example
      {MultiBinding Source={Binding ItemId=Tube}, Filter={CompositeFilter F1=OrderBy}}

      In the example above, the filter sorts all tubes in ascending order.

    • OrderByDescending: IFilter

      Sorts available items in descending order.

      Example
      {MultiBinding Source={Binding ItemId=Tube}, Filter={CompositeFilter F1=OrderByDescending}}

      In the example above, the filter sorts all tubes in descending order.

    • DescendantElements: IFilter

  • FilterParameter : object

    Parameter to be used by the filter.

  • Aggregate : Aggregate

    A function to be used for aggregation of collection items.

    Allowed values:

    • None - default value, no aggregation happens and collection of items is returned
    • Sum - sum of all items. Items must be numbers
    • Product - product of all items. Items must be numbers
    • Max - a largest item in a collection. Items must be numbers
    • Min - a smallest item in a collection. Items must be numbers
    • Average - average value of collection items. Items must be numbers
    • AllTrue - all values in collection are True. Items must be boolean
    • AllFalse - all values in collection are False. Items must be boolean
    • AnyTrue - at least one item in collection has value True. Items must be boolean
    • AnyFalse - at least one item in collection has value False. Items must be boolean
    • Count - amount of items in a collection
    • Any - True if collection has at least one item and False otherwise
    • Single - a single item of a collection. Null if collection has no items. Error is thrown if collection has more than one item
    • First - a first item of a collection. Null if collection has no items
    • Last - a last item of a collection. Null if collection has no items
    Example
                          <
                          Field Id="Field_TubesCount" Value="{MultiBinding Source={Binding ItemId=Tube}, Aggregate=Count}" />
    <Field Id="Field_AllTubesClickable" Value="{MultiBinding IsClickable, Source={Binding ItemId=Tube},  Aggregate=AllTrue}" />
    <Field Id="Field_AllTubesClickable" Value="{MultiBinding Source={Binding ItemId=Tube}, Filter=Conditional, FilterParameter=${Binding IsClickable, Converter=Invert}, Aggregate=Any}" />
    <Field Id="Field_AllTubesClickedAtLeastTwice" Value="{MultiBinding Source={Binding ItemId=Tube}, Expression=${Binding ClickCount, Converter=GreaterThanOrEquals, ConverterParameter=2}, Aggregate=AllTrue}" />
    <Field Id="Field_AtLeastOneTubeClickedAtLeastThreeTimes" Value="{MultiBinding Source={Binding ItemId=Tube}, Expression=${Binding ClickCount, Converter=GreaterThan, ConverterParameter=2}, Aggregate=AnyTrue}" />