locked
How do I update a data source using a multitrigger? RRS feed

  • Question

  • To update a control properties I use the following:

                    <ControlTemplate.Triggers>
                      <MultiDataTrigger>
                        <MultiDataTrigger.Conditions>
                          <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsSelected}" Value="True"/>
                          <Condition Binding="{Binding Path=IsSomeConditionSetArrived}" Value="True"/>
                        </MultiDataTrigger.Conditions>
                        <Setter Property="TabItem.Foreground" Value="Red"/>
                      </MultiDataTrigger>
                    </ControlTemplate.Triggers>

    How can I update the data source ({Binding Path=IsSomeConditionSetArrived}) or raise the RoutedCommand with same set of conditions like this?
    Monday, March 24, 2008 2:59 PM

Answers

  • I solve this problem. I use a IMultiValueConverter to set value of the data source:

                      <MultiDataTrigger>
                        <MultiDataTrigger.Conditions>
                          <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsSelected}" Value="True"/>
                          <Condition Binding="{Binding Path=IsSomeConditionSetArrived}" Value="True"/>
                        </MultiDataTrigger.Conditions>
                        <Setter Property="Tag">
                          <Setter.Value>
                            <MultiBinding Converter="{StaticResource AddTabConverter}">
                              <!-- TabItem data -->
                              <Binding/>
                              <!-- TabControl.ItemsSource -->
                              <Binding Mode="OneWay"
                                       RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType={x:Type TabControl}}"
                                       Path="ItemsSource"/>
                              <!-- TabItem.IsSelected -->
                              <Binding RelativeSource="{RelativeSource Self}" Path="IsSelected"/>
                              <!-- TabItem data is SomeConditionSet Arrived -->
                              <Binding Path="IsSomeConditionSetArrived"/>
                            </MultiBinding>
                          </Setter.Value>
                        </Setter>

                      </MultiDataTrigger>

    Thanks.
    Monday, March 24, 2008 8:57 PM