cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
overhead_press2
Frequent Visitor

How to switch icon when clicked?

Greetings, how do I change the icon when its pressed? For example, I currently have the "+" icon and I want it to change to the Save icon after + icon is pressed. Any help would be appreciated! 

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@overhead_press2 

In the OnSelect of the Icon - UpdateContext({lclIcon: Switch(lclIcon, "Save", "Add", "Add", "Save")})

In the Icon property: 
    Switch(Coalesce(lclIcon, "Add"), "Add", Icon.Add, "Save", Icon.Save)

 

Now, I gave the above which is a little overkill, but the concept above is that you might also want something else in the future beside "Add" or "Save"...you can then just add them into the formula.

 

IF you ONLY want the two states, then you can simplify to this:

   UpdateContext({lclIcon: !Coalesce(lclIcon, true)})

And the Icon property to:

   If(Coalesce(lclIcon, true), Icon.Add, Icon.Save)

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

1 REPLY 1
RandyHayes
Super User
Super User

@overhead_press2 

In the OnSelect of the Icon - UpdateContext({lclIcon: Switch(lclIcon, "Save", "Add", "Add", "Save")})

In the Icon property: 
    Switch(Coalesce(lclIcon, "Add"), "Add", Icon.Add, "Save", Icon.Save)

 

Now, I gave the above which is a little overkill, but the concept above is that you might also want something else in the future beside "Add" or "Save"...you can then just add them into the formula.

 

IF you ONLY want the two states, then you can simplify to this:

   UpdateContext({lclIcon: !Coalesce(lclIcon, true)})

And the Icon property to:

   If(Coalesce(lclIcon, true), Icon.Add, Icon.Save)

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Helpful resources

Announcements
Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Super User 2 - 2022 Congratulations

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Users online (2,975)