Sporran
Sporran

Reputation: 11

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.

Upvotes: 0

Views: 4396

Answers (2)

SeaDude
SeaDude

Reputation: 4365

I believe you could also simplify this by using ThisItem.IsSelected for the visible property of the button.

Upvotes: 1

Sporran
Sporran

Reputation: 11

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 :)

Upvotes: 1

Related Questions