1

How to retrieve (using code-behind) binding expression from control bounded with using MultiBinding?

denny
  • 320
  • 3
  • 10

1 Answers1

2

Using BindingOperations.GetMultiBindingExpression method.

Example:

        <TextBlock x:Name="MyTextBlock">
            <TextBlock.Text>
                <MultiBinding Converter="{StaticResource myConverter}">
                    <Binding ElementName="lst" Path="Items.Count" />
                    <Binding ElementName="txtName" Path="Text" />
                    <Binding ElementName="txtAge" Path="Text" />
                </MultiBinding>
            </TextBlock.Text>
        </TextBlock>

Accesing it from code:

TextBlock textblock = FindName("MyTextBlock") as TextBlock;
var bindingExpression = BindingOperations.GetMultiBindingExpression(textblock, TextBlock.TextProperty);

Hope this helps

Omri Btian
  • 6,499
  • 4
  • 39
  • 65