Alex Rivera | Logout

How can I pass a constant value for 1 binding in multi-binding?

Asked 2010-07-27T04:49:24.320
121

I have a multi-binding like

<TextBlock>
    <TextBlock.Text>
        <MultiBinding Converter="{StaticResource myConverter}">
            <Binding Path="myFirst.Value" />
            <Binding Path="mySecond.Value" />
        </MultiBinding>
    </TextBlock.Text>
</TextBlock>

And I want to pass a fixed value e.g. "123" to one of the two bindings above. How can I do that using XAML?

Edit
Report

1 Answer

127

Or, combining the two answers above:

Define the namespace sys at the document head:

xmlns:sys="clr-namespace:System;assembly=mscorlib"

and then:

<MultiBinding Converter="{StaticResource ScalingConverter}">
    <Binding>
        <Binding.Source>
            <sys:Double>0.5</sys:Double>
        </Binding.Source>
    </Binding>
    <Binding ElementName="TC" Path="ActualWidth" />
</MultiBinding>

Which provides the right type without the Resources kludge.

answered 2012-07-14T20:43:25.883

Your Answer