MultiBinding in Silverlight 3

How to implement MultiBinding in Silverlight 3?

+3
source share
2 answers

Here is an implementation that works slightly differently: http://www.olsonsoft.com/blogs/stefanolson/post/Improvements-to-Silverlight-Multi-binding-support.aspx It allows you to write code as follows:

<TextBlock x:Name="Block" Foreground="White" FontSize="13"
           Margin="5,0,0,0">
    <local:BindingUtil.MultiBindings>
        <local:MultiBindings>
            <local:MultiBinding TargetProperty="Text" Converter="{StaticResource TitleConverter}">
                <Binding Path="Surname"/>                            
                <Binding Path="Forename"/>
            </local:MultiBinding>
            <local:MultiBinding TargetProperty="Visibility" Converter="{StaticResource TitleToVisibiltyConverter}">
                <Binding Path="Surname"/>                            
                <Binding Path="Forename"/>
            </local:MultiBinding>
        </local:MultiBindings>
    </local:BindingUtil.MultiBindings>
</TextBlock>

I usually don’t like to get attached to people's blogs, but the code is just too big to post.

+3
source

Here is one implementation that allows up to 5 bindings: http://www.thejoyofcode.com/MultiBinding_for_Silverlight_3.aspx It allows you to write code as follows:

<binding:MultiBinding x:Name="mb" Converter="{StaticResource intsToBrushConverter}"
    NumberOfInputs="3"
    Input1="{Binding ElementName=red, Path=Value, Mode=TwoWay}"
    Input2="{Binding ElementName=green, Path=Value, Mode=TwoWay}"
    Input3="{Binding ElementName=blue, Path=Value, Mode=TwoWay}" />

<Border Background="{Binding ElementName=mb, Path=Output}" Margin="5"/>
0
source

Source: https://habr.com/ru/post/1738441/


All Articles