cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
chico
Advocate V
Advocate V

Change Color of icon - OnSelect

Fishing for an idea;

 

I have an icon, that Selects an item from a Gallery to then add to a collection.

The Color Property has a simple if statement  if the item already exists in that collection.

 If(
    Not( ThisItem.'Name' in colAsset.'Name'),
    DarkGreen,
    DarkRed
)

The above works just fine.

 

I'm fishing for ideas on how to change the color property, of an icon, by using the OnSelect of that same icon.

 

So for a rough example of the goal;

"icon4" with a color property that defaults to DarkGreen,

 

would like to somehow create an if statement in the OnSelect;

 

If(
    Icon4.Color=DarkGreen,
    <set color to> Dark red,
    <set color to> DarkGreen
)

 

What could possibly be put in place of the <set color to> to update that property?

 

Doing this as an exercise to get away from using variables and use more if statements.

1 ACCEPTED SOLUTION

Accepted Solutions
TheRobRush
Super User
Super User

Because a control is far more of a tax on an app than a variable. Thinking code wise the state of the control all by itself is a variable. Then you have its height width color fill hover info x y etc. A control is just a bundle of variables to a computer.

 

Included some of Microsofts best practices for app performance below. You will see limiting controls is on their. Variables not so much

 

Performance Tips 

_____________________________________________________________________________________
Like my answer? - Hit that Thumbs Up. Resolved the Issue? - Hit Accept as Solution.
This helps others find solutions to future issues!

View solution in original post

6 REPLIES 6
TheRobRush
Super User
Super User

Set(colorVar, RGBA(156, 96, 178, 1))

and set the color value to colorVar

_____________________________________________________________________________________
Like my answer? - Hit that Thumbs Up. Resolved the Issue? - Hit Accept as Solution.
This helps others find solutions to future issues!

but your proposal is using a Variable and I'm looking to reduce the use of Variables.

chico
Advocate V
Advocate V

welp,

I reached my goal with a transparent toggle button on top, 

color properties based on toggle value.

 

would be nice to do it all in one control, but seems like its not possible.

TheRobRush
Super User
Super User

No, you cant change it solely based on clicking a button unless clicking the button changes it's state which it only does in toggles etc. You can always base the color off a countrows of your collection where itemname=thisitem.itemname and that will work if the items are unique. If this was just an exercise at least you found a way. If this is for actual use it would be far more app friendly to use the variable though.

_____________________________________________________________________________________
Like my answer? - Hit that Thumbs Up. Resolved the Issue? - Hit Accept as Solution.
This helps others find solutions to future issues!
chico
Advocate V
Advocate V

-->>>If this is for actual use it would be far more app friendly to use the variable though.

 

Curious...

Why would a Variable be better option?

I've read elsewhere that reducing the number of variables can improve performance.

TheRobRush
Super User
Super User

Because a control is far more of a tax on an app than a variable. Thinking code wise the state of the control all by itself is a variable. Then you have its height width color fill hover info x y etc. A control is just a bundle of variables to a computer.

 

Included some of Microsofts best practices for app performance below. You will see limiting controls is on their. Variables not so much

 

Performance Tips 

_____________________________________________________________________________________
Like my answer? - Hit that Thumbs Up. Resolved the Issue? - Hit Accept as Solution.
This helps others find solutions to future issues!

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.

Top Kudoed Authors
Users online (3,052)