Databind switches

Hi,

I am trying to figure out how to bind multiple switches to one switch.

Im pulling a list of names that can be selected with a switch from a JSON file. I also added a extra item to the list which is suppose to be a “select all” switch.

Is this posible and if so how do i do this?

here’s my code and a visual representation of what im trying to do.

<StackPanel Margin="10,0,10,0" Height="50%">
            <Panel>
                <Text Value="Select all" Alignment="CenterLeft" Margin="10,0,0,0" />
                <Switch Alignment="CenterRight"/>
            </Panel>
            <FineLine />
            <Each Items="{data.persons}">
                <Panel>
                    <Text Width="200" Value="{name}" Alignment="CenterLeft" TextWrapping="NoWrap" Margin="10,0,0,0" />
                    <Switch Alignment="CenterRight" Value="{isSelected}"/>
                </Panel>
            <FineLine />
            </Each>
        </StackPanel>

file

For those that are trying the same thing. I solved it using this code

My code now looks like this:

<Each Items="{data.persons}">
    <Panel>
        <Text Width="200" Value="{name}" Alignment="CenterLeft" TextWrapping="NoWrap" Margin="10,0,0,0" />
        <DependSwitch Master="{groupOne}" Alignment="CenterRight" Value="{selected}" />
        </Panel>
<FineLine />

And I added this line to my MainView.js exports.

groupOne: groupOne = Observable(false)