cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Keltanis
Microsoft
Microsoft

Trying to do ANYTHING on click of an image

A newbie here (1st time with Power Apps). I am trying to either hide a label or change it's color when an image is clicked. You know, basic stuff. 

 

Using the attached image for reference --

For the image named "btn", I have tried using the OnSelect with:

btn.Visible=false

and 

Label2.Color = Red

However, nothing changes when I run it.

Ideas?

2 ACCEPTED SOLUTIONS

Accepted Solutions
Drrickryp
Super User
Super User

Hi @Keltanis 

Use a context variable to make your changes. In the OnSelect property of the image: UpdateContext({var:false, clr:Red}) and set the Visible property of the control to var and the color property of label2 as clr. In the OnVisible property of the screen containing the controls use UpdateContext({var:true, clr:green})  as an example of setting the default property of the image and the label.

View solution in original post

Thanks. This worked the best for what I was trying to do.

View solution in original post

3 REPLIES 3
Drrickryp
Super User
Super User

Hi @Keltanis 

Use a context variable to make your changes. In the OnSelect property of the image: UpdateContext({var:false, clr:Red}) and set the Visible property of the control to var and the color property of label2 as clr. In the OnVisible property of the screen containing the controls use UpdateContext({var:true, clr:green})  as an example of setting the default property of the image and the label.

CarlosFigueira
Power Apps
Power Apps

Welcome to the Power Apps platform :). To do what you want, you can use a variable that would be bound to the visibility (or the color), and change that in the OnSelect property of your image.

For example, if you set the initial values in the App.OnStart property:

Set(buttonVisibility, true);
Set(labelColor, Color.White)

And set the Visible property of the button to 'buttonVisibility' and the Color property of the label to 'labelColor', you can change the visibility and color with this expression in the OnSelect property of your image:

Set(buttonVisibility, false);
Set(labelColor, Color.Red)

 Hope this helps!

Thanks. This worked the best for what I was trying to do.

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (3,015)