Search code examples
wpfxamlbindingmultibinding

WPF Mutibinding two or more binding on TextBlock Text


whe I build this style xaml code, gets back this error:

Severity Code Description Project File Line Suppression State Error A 'Binding' cannot be set on the 'Path' property of type 'Binding'. A 'Binding' can only be set on a DependencyProperty of a DependencyObject

How I can multibinding this binding properties? thanks in advance.

 <Style x:Key="TextBlockLastUnitStyle" TargetType="TextBlock">
    <Setter Property="Text">
        <Setter.Value>
            <MultiBinding StringFormat="{}{0} : {1}">
                <Binding Path="{Binding String57, Source={StaticResource CurrentResources}}" />
                <Binding Path="{Binding LastUnitId,FallbackValue=-.-}" />
            </MultiBinding>
        </Setter.Value>
    </Setter>        
</Style>

Solution

  • The Bindings in a MultiBinding use XML tag syntax instead of attribute syntax:

    <Style x:Key="TextBlockLastUnitStyle" TargetType="TextBlock">
        <Setter Property="Text">
            <Setter.Value>
                <MultiBinding StringFormat="{}{0} : {1}">
                    <Binding Path="String57" Source="{StaticResource CurrentResources}"/>
                    <Binding Path="LastUnitId" FallbackValue="-.-" />
                </MultiBinding>
            </Setter.Value>
        </Setter>
    </Style>