How can I set Switch position?

Hi,

I want to dim_value value greater than 0 if the switch on. The following code does not work. Do you have any idea?

<App Background="#A64942">
    <JavaScript>
        var Observable = require("FuseJS/Observable");

        var data = Observable(
            {name: "foo", dim_value: 0}, 
            {name: "bar", dim_value: 43});

        module.exports = {
            data: data
        };
    </JavaScript>

    <ScrollViewer>
        <StackPanel>
            <Each Items="{data}">
                <Panel>
                    <Text Value="{name}" />
                    <WhileFloat GreaterThan="1" LessThan="255" Value="{dim_value}">
                        <Switch Value="true" />
                    </WhileFloat>
                </Panel>
            </Each>
        </StackPanel>
    </ScrollViewer>
</App>

Sorry, I did not understand this part:

I want to dim_value value greater than 0 if the switch on.

Can you please rephrase what you want to acheive?

In your above code, the switch will only be visible while 1 < dim_value < 255.

If the “dim_value” variable to 0, I want the switch to be closed. If the “dim_value” variable if it is between 1 and 255, the switch turned on I want to be.

In your above code, the switch will only be visible while 1 < dim_value < 255.

I want to do switch will only be “OPEN” position while 1 < dim_value < 255.

You want a Switch that is on when a particular value is within a given range, correct?

This is something like this:

<Switch Value="False" ux:Name="TheSwitch" IsEnabled="False"/>
<WhileFloat Value="{dim_value}" GreaterThan="1" LessThan="255">
    <Change TheSwitch.Value="True"/>
</WhileFloat>

I put IsEnabled="False" on the switch since I assume you don’t want the user to be able to toggle it on/off (since you are controlling that state with the WhileFloat).

It’s work! Thank you.