'How to properly use an If statement in PowerApps when trying to toggle visibility of an element?
I would like to toggle the visible property of a button that is nested in a Gallery in my PowerApp.
What I tried to was to go off of whether the parent was selected. I placed this formula inside the Visible property.
ink its a type issue, but I am not sure what is the best way to fix this.
If(Parent.Selected = true, true, false)
I received an "Invalid argument type" error on the "=" operator, so I think that perhaps I have a type mismatch or some other issue.
Solution 1:[1]
I feel like an idiot, because about 5 minutes after I asked the question I figured out the answer.
All I had to do was to use the followng as the conditional statement:
ThisItem.IsSelected
The full solution being:
If(ThisItem.IsSelected,true,false)
Maybe this can help another rookie too :)
Solution 2:[2]
I believe you could also simplify this by using ThisItem.IsSelected for the visible property of the button.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Sporran |
| Solution 2 | SeaDude |
