<Toggle> Feature

It would be really awesome to be able to use <Toggle> to toggle between multiple values like so:

<Panel ux:Name="panel></Panel>
<Button>
 <Clicked>
   <Toggle Target="panel.Visibility" Values="Visible,Hidden" />
 </Clicked>
</Button>

Where the Values are comma seperated, and Toggle will just keep on toggling between each value (left to right)

This type of behaviour is generally accomplished using While... triggers. In this case you might want something like this instead:

<Panel ux:Name="panel" Visibility="Hidden">
   <WhileBool ux:Name="Revealed">
       <Change panel.Visibility="Visible"/>
   </WhileBool>
</Panel>

<Button>
   <Clicked>
        <Toggle Target="Revealed"/>
   </Clicked>
</Button>

This approach is built around a state model rather than an imperative model. Typically the While... trigger may do several things as well, and this groups them together. It also creates a logical group of changes, and is state stable (you won’t accidentally get into an irreversible or inconsistent state when using change and transfrom animators).

If you have more than two states to toggle you can use the StateGroup.

Yea that’s the way I do it now, but if you want multiple things to toggle through then how would you use StateGroup could you show me an example?

This feature would allow for a whole bunch of things, changing text of a button, colors etc.

How is this done with StateGroup and it still might be useful to have this because less code, all I have to do is add a comma and value to the Values property of Trigger

A stategroup has this basic form:

<StateGroup ux:Name="TheGroup">
    <State ux:Name="StateA">
        <Change .../>
    </State>
    <State ux:Name="StateB">
        <Change .../>
    </State>
     ...

To switch the state use <Set TheGroup.Active="StateB"/>.

If you have a use-case where your syntax would be shorter, and still clear, then please post it. It’d give me a better idea of how to consider a potential new feature. By use-case I mean a full scenario where it would be used, so I get a full picture of how it would work.

It’s still possible with StateGroup etc, but here’s a usecase:

<Panel ux:Name="panel"></Panel>
<Button Text="Change Color">
  <Clicked>
    <Toggle Target="panel.Background" Values="#fff,#000,#f00,#0f0,#00f" />
  </Clicked>
</Button>

With StateGroup to switch between each color, I’d somehow have to keep track of which color is set, and then switch to the next state

You can use <TransitionState Target="TheState" Type="Next"/> to move to the next state in a state group.

Still much more code, because for each color you’ll need a <State> and <Change>, and still need the <StateGroup. One could always use an <Each> to make a <State> for each color, but again its more work for simple values. Its still obviously very useful for complex things, because you may have animation and all sorts of things, but having <Toggle Target="..." Value="..." /> is much simpler.

To all people viewing this, if you agree with this feature please say something, this is how the Fuse team knows whether is worth implementing. (I’m just one person) Thanks

Here, here, this would be nice to have…