# \<Set\> not working in \<Case\>

**URL:** <https://forums.fusetools.com/t/set-not-working-in-case/3331>\
**Category:** Bug Reports\
**Created:** [July 25, 2016, 11:00pm UTC](https://forums.fusetools.com/t/set-not-working-in-case/3331 "2016-07-25T23:00:20Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![paul70079](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/paul70079/32/324_2.png) [@paul70079](https://forums.fusetools.com/u/paul70079)\
**Post date:** [July 25, 2016, 11:00pm UTC](https://forums.fusetools.com/t/set-not-working-in-case/3331/1 "2016-07-25T23:00:20Z")

</div>

Somehow the `<set>`-element isn’t working inside a case element in my sample:

```auto
<Switch ux:Name="mSwitch">
    <Clicked>
        <Match Value="{mSwitch.Value}">
            <Case Bool="true">
                <Set mText.Value="on" />
            </Case>
            <Case Bool="false" >
                <Set mText.Value="off" />
            </Case>
        </Match> 
    </Clicked>
</Switch>
<Text ux:Name="mText" >
    off
</Text>

```

If I move the `<set>`-lines outside the `<case>` it works

Error message:

```auto
'Set' does not have an attached property called 'mText.Value', nor does it support implicit set-properties

```

---

<div class="post-metadata">

**Author:** ![Edwin\_Reynoso](https://avatars.discourse-cdn.com/v4/letter/e/e99b99/32.png) [@Edwin\_Reynoso](https://forums.fusetools.com/u/Edwin_Reynoso)\
**Post date:** [July 25, 2016, 11:38pm UTC](https://forums.fusetools.com/t/set-not-working-in-case/3331/2 "2016-07-25T23:38:07Z")

</div>

Try using

```auto
<Text ux:Name="mText" Value="off" />

```

and for set use:

```auto
<Set Target="mText" Value="on" />
<Set Target="mText" Value="off" />

```

That should work, and use that pattern across it makes everything easier

---

<div class="post-metadata">

**Author:** ![paul70079](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/paul70079/32/324_2.png) [@paul70079](https://forums.fusetools.com/u/paul70079)\
**Post date:** [July 26, 2016, 8:16am UTC](https://forums.fusetools.com/t/set-not-working-in-case/3331/3 "2016-07-26T08:16:51Z")

</div>

Changed it to:

```auto
<Switch ux:Name="mSwitch">
    <Clicked>
        <Set Target="mDebug.Value" Value="{Property mText.Value}" />
        <Match Value="{Property mSwitch.Value}">
            <Case Bool="true">
                <Set Target="mText.Value" Value="on" />
            </Case>
            <Case Bool="false" >
                <Set Target="mText.Value" Value="off" />
            </Case>
        </Match> 
    </Clicked>
</Switch>
<Text ux:Name="mText" Value="off" />

```

But now getting problems because `<Match>` doesn’t seem to accept bools.

---

<div class="post-metadata">

**Author:** ![Kristian\_Hasselknipp](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/kristian_hasselknipp/32/549_2.png) [@Kristian\_Hasselknipp](https://forums.fusetools.com/u/Kristian_Hasselknipp)\
**Post date:** [July 26, 2016, 9:55am UTC](https://forums.fusetools.com/t/set-not-working-in-case/3331/4 "2016-07-26T09:55:28Z")

</div>

Try moving the Match outside of the Clicked trigger. It will not be rooted unless the clicked trigger is active, which it will only be for an instant in this case.

Something like this:

```auto
<Switch ux:Name="mSwitch">
    <Clicked>
        <Set Target="mDebug.Value" Value="{Property mText.Value}" />
    </Clicked>
    <Match Value="{Property mSwitch.Value}">
        <Case Bool="true">
            <Set Target="mText.Value" Value="on" />
        </Case>
        <Case Bool="false" >
            <Set Target="mText.Value" Value="off" />
        </Case>
    </Match> 
</Switch>
<Text ux:Name="mText" Value="off" />

```

---

<div class="post-metadata">

**Author:** ![paul70079](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/paul70079/32/324_2.png) [@paul70079](https://forums.fusetools.com/u/paul70079)\
**Post date:** [July 26, 2016, 9:57am UTC](https://forums.fusetools.com/t/set-not-working-in-case/3331/5 "2016-07-26T09:57:49Z")

</div>

Still getting Error: ``Cannot bind property 'Value' (object) to 'Value' (bool), the types don't match. If you created the property 'Value', consider changing its type to 'object'.`

---

<div class="post-metadata">

**Author:** ![Edwin\_Reynoso](https://avatars.discourse-cdn.com/v4/letter/e/e99b99/32.png) [@Edwin\_Reynoso](https://forums.fusetools.com/u/Edwin_Reynoso)\
**Post date:** [July 26, 2016, 7:22pm UTC](https://forums.fusetools.com/t/set-not-working-in-case/3331/6 "2016-07-26T19:22:52Z")

</div>

Can you show more code can’t tell what is `mDebug`

---

<div class="post-metadata">

**Author:** ![paul70079](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/paul70079/32/324_2.png) [@paul70079](https://forums.fusetools.com/u/paul70079)\
**Post date:** [July 26, 2016, 7:37pm UTC](https://forums.fusetools.com/t/set-not-working-in-case/3331/7 "2016-07-26T19:37:01Z")

</div>

Complete Code:

```auto
<App>
    <StackPanel Alignment="Center">
        <Switch ux:Name="mSwitch">
            <Clicked>
                <Set Target="mDebug.Value" Value="{Property mText.Value}" />

            </Clicked>
            <Match Value="{Property mSwitch.Value}">
                    <Case Bool="true">
                        <Set Target="mText.Value" Value="on" />
                    </Case>
                    <Case Bool="false" >
                        <Set Target="mText.Value" Value="off" />
                    </Case>
                </Match> 
        </Switch>
        <Text ux:Name="mText" Value="off" />
        <Text ux:Name="mDebug" Value="{Property mText.Value}" />
    </StackPanel>
</App>

```

mDebug is only a text element for debug purposes

---

<div class="post-metadata">

**Author:** ![Edwin\_Reynoso](https://avatars.discourse-cdn.com/v4/letter/e/e99b99/32.png) [@Edwin\_Reynoso](https://forums.fusetools.com/u/Edwin_Reynoso)\
**Post date:** [July 26, 2016, 8:04pm UTC](https://forums.fusetools.com/t/set-not-working-in-case/3331/8 "2016-07-26T20:04:11Z")

</div>

So it seems like this is not possible not sure if a bug or intended:

```auto
<App>
    <StackPanel Alignment="Center">
        <Switch ux:Name="mSwitch" />
        <Text ux:Name="mText" Value="{Property mSwitch.Value}" />
    </StackPanel>
</App>

```

But here’s what you want:

```auto
<App>
    <StackPanel Alignment="Center">
        <Switch ux:Name="mSwitch" />
        <WhileTrue Value="{Property mSwitch.Value}">
            <Change Target="mText.Value" Value="on" />
        </WhileTrue>
        <Text ux:Name="mText" Value="off" />
    </StackPanel>
</App>

```

---

<div class="post-metadata">

**Author:** ![paul70079](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/paul70079/32/324_2.png) [@paul70079](https://forums.fusetools.com/u/paul70079)\
**Post date:** [July 26, 2016, 8:20pm UTC](https://forums.fusetools.com/t/set-not-working-in-case/3331/9 "2016-07-26T20:20:54Z")

</div>

It works now!

Thanks 🙂

I don’t think its still a bug

---

<div class="post-metadata">

**Author:** ![Edwin\_Reynoso](https://avatars.discourse-cdn.com/v4/letter/e/e99b99/32.png) [@Edwin\_Reynoso](https://forums.fusetools.com/u/Edwin_Reynoso)\
**Post date:** [July 26, 2016, 8:23pm UTC](https://forums.fusetools.com/t/set-not-working-in-case/3331/10 "2016-07-26T20:23:54Z")

</div>

What I don’t understand is why it doesn’t display the boolean text `true` or `false` with:

```auto
<App>
    <StackPanel Alignment="Center">
        <Switch ux:Name="mSwitch" />
        <Text ux:Name="mText" Value="{Property mSwitch.Value}" />
    </StackPanel>
</App>

```

It’s because of the types but it should convert the boolean to string

---

<div class="post-metadata">

**Author:** ![edA-qa\_mort-ora-y](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/eda-qa_mort-ora-y/32/124_2.png) [@edA-qa\_mort-ora-y](https://forums.fusetools.com/u/edA-qa_mort-ora-y)\
**Post date:** [July 27, 2016, 7:29am UTC](https://forums.fusetools.com/t/set-not-working-in-case/3331/11 "2016-07-27T07:29:02Z")

</div>

`{Property x}` is a 2-way binding thus it can’t perform any conversions. I believe we have a feature request to provide a 1-way bindable version that will allow type conversions.
