0
votes

I want that that when a property change, analize the values of the properties and set the text of a text block. I have this:

With multi binding:

<TextBlock>
    <TextBlock.Text>
        <MultiBinding Converter="{StaticResource MyMultivalueConverter}">
            <Binding />
            <Binding Path="AnotherProperty"/>
        </MultiBinding>
    </TextBlock.Text>
</TextBlock>

With multi data trigger:

<TextBlock HorizontalAlignment="Center" Margin="0,20,0,0" FontSize="28">
    <TextBlock.Style>
        <Style TargetType="TextBlock">
            <Style.Triggers>
                <MultiDataTrigger>
                    <MultiDataTrigger.Conditions>
                        <Condition Binding="{Binding Path=." Value="0" />
                        <Condition Binding="{Binding Path=AnotherProperty}" Value="True" />
                    </MultiDataTrigger.Conditions>
                    <Setter Property="Text" Value="Mytext" />
                </MultiDataTrigger>
            </Style.Triggers>
        </Style>
    </TextBlock.Style>
</TextBlock>

The main difference that I see is that in the multibinding I need a multi value converter. However, with the multi data trigger, I need to set all the combinations to set the differents texts that I want to display according to the values of the properties, so this is a very hard work.

So my doubt is which is the advantege of multi data trigger, because I need to set many combinations and with the multi binding I create a converter that also allows complex comparations like greater than, less than... With multi data trigger only a value for each combination.

In sumary, when to use multi binding and when multi data trigger? Which are the advantages of multi binding and the advantages of the multi data trigger?

thank so much.

1

1 Answers

1
votes

In case of MultiDataTrigger you set property in xaml and thanks to that you can use resources, data binding etc in order to set property's value to desired what it is not possible in MultiBinding (unless you send resource in another binding and retrieve it from parameters or write custom converter). Example:

 <Setter Property="Text" Value="{StaticResource YourResource}" />

By using Converter, no matter whether from Binding or MultiBinding, you can track data by inserting breakpoints in Convert or ConvertBack method, what is not possible in xaml directly.

Your concern which one is more useful vanishes in Silverlight where both do not exist.