0
<MultiDataTrigger>
    <MultiDataTrigger.Conditions>
        <Condition>
            <Condition.Binding>
                <MultiBinding Converter="{StaticResource BooleanOr}">
                    <Binding Path="Property Value =5"/>
                    <Binding Path="Property Value =10"/>
                </MultiBinding>
            </Condition.Binding>
        </Condition>
    </MultiDataTrigger.Conditions>

///Do something here based on condition....

The code means when Value eqauls 5 or 20 ===> Do something.

I followed this one for multi-triggers

But "Binding Path="Property Value =5"" this line obviously is wrong.

What should I write here in order to compare Value is 5 or not Thank you!

Anatoliy Nikolaev
  • 22,370
  • 15
  • 69
  • 68
Anders Lind
  • 4,542
  • 8
  • 46
  • 59

2 Answers2

0

If you do not have more than one condition you do not need a MultiDataTrigger.

If you want to compare to a value you could use a converter where the Binding.ConverterParameter is set to said value. The converter would just compare the value and parameter (possibly with parsing applied to the parameter if it is not passed as an int)

Do not put anything besides the property path into the Path of course. The converter should directly return true or false as this presumably is expected by the MultiBinding.Converter.

H.B.
  • 166,899
  • 29
  • 327
  • 400
  • actually I have lot of to compare. I want to trigger the action when value from 0 ~ 20 actually. Can you give me some code example how to do this? thanks. – Anders Lind Jan 11 '12 at 17:15
  • @AndersLind: I will not, if need an example for a converter look at the reference i linked. And comparing values and parsing strings hardly needs an example either, if it does you might want to look at the `Parse` and `TryParse` methods which can be found on about every primitive type. – H.B. Jan 11 '12 at 18:24
0

You'll need another converter to see if one value is equal to whatever value you're comparing against

<MultiBinding Converter="{StaticResource BooleanOr}">
    <Binding Path="Value" ConverterParameter="5" Converter="{StaticResource IsValueEqualParameterConverter}" />
    <Binding Path="Value" ConverterParameter="10" Converter="{StaticResource IsValueEqualParameterConverter}" />
</MultiBinding>

Another option is to use DataTriggers

<Style>
    <Setter Property="SomeProperty" Value="FalseValue" />
    <Style.Triggers>
        <DataTrigger Binding="{Binding Value}" Value="5">
            <Setter Property="SomeProperty" Value="TrueValue" />
        </DataTrigger>
        <DataTrigger Binding="{Binding Value}" Value="10">
            <Setter Property="SomeProperty" Value="TrueValue" />
        </DataTrigger>
    </Style.Triggers>
</Style>
Rachel
  • 130,264
  • 66
  • 304
  • 490