mshvern23
Topic Author
Posts: 35
Joined: 22 May 2023, 02:00

GoToStateAction on MultiDataTrigger

15 Jun 2023, 04:31

Is this something that's possible? I'm trying to refactor my BeginStoryboard set-up into visual states, but I can't add
<b:GoToStateAction StateName="SomeState"/>
to a MultiDataTrigger.EnterActions.

Is it possible to achieve a similar effect without using any code? With MultiDataTrigger s I can define states that are entered with as many conditions as I want all in XAML.
Would my only option be creating a custom control instead of a control template and adding a code-behind for it?
 
User avatar
sfernandez
Site Admin
Posts: 3363
Joined: 22 Dec 2011, 19:20

Re: GoToStateAction on MultiDataTrigger

15 Jun 2023, 10:34

You can only use interactivity actions inside interactivity triggers, so instead of having a MultiDataTrigger in the template Triggers, you will have DataTrigger (or anything else you need) plus ConditionBehavior in an element of the visual tree:
<ControlTemplate ...>
  <Grid>
    <b:Interaction.Triggers>
      <b:DataTrigger Binding="{Binding Something}" Value="True">
        <b:Interaction.Behaviors>
          <b:ConditionBehavior>
            <b:ConditionalExpression ForwardChaining="And">
              <b:ComparisonCondition LeftOperand="{Binding Count}" Operator="LessThan" RightOperand="0" />
              <b:ComparisonCondition LeftOperand="{Binding Count}" Operator="GreaterThan" RightOperand="100" />
            </b:ConditionalExpression>
          </b:ConditionBehavior>
        </b:Interaction.Behaviors>
        <b:GoToStateAction StateName="SomeState"/>
      </b:DataTrigger>
    </b:Interaction.Triggers>
    ...
  </Grid>
</ControlTemplate>
Could you try that?

Who is online

Users browsing this forum: No registered users and 2 guests