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

Changing another object property with a button/ image click

Hi

 

How can i play a sound and/or change another object's properties when "clicking" on a button/image (for example change the backcolor of a textbox when clicking a button)?

 

thank you!

1 ACCEPTED SOLUTION

Accepted Solutions
Power Apps
Power Apps

Hi dantept,

 

One option to do that is to bind the property you want to change to a context variable that will be changed when the button is clicked. For example, if you want to change the background color of textbox, you'd set the Fill property to that variable:

 

TextBox1.Fill: myColor

And then on the OnSelect property of the button, you'd update the value. In the example below, the color is toggled between red and blue every time the button is pressed.

 

Button1.OnSelect: UpdateContext({ myColor: If(myColor = Color.Red, Color.Blue, Color.Red) })

You can also have an initial value for that variable, which would be normally set on the OnVisible property of the screen where the textbox and button are located:

 

Screen1.OnVisible: UpdateContext({ myColor: Color.Red }) 

 

View solution in original post

3 REPLIES 3
Power Apps
Power Apps

Hi dantept,

 

One option to do that is to bind the property you want to change to a context variable that will be changed when the button is clicked. For example, if you want to change the background color of textbox, you'd set the Fill property to that variable:

 

TextBox1.Fill: myColor

And then on the OnSelect property of the button, you'd update the value. In the example below, the color is toggled between red and blue every time the button is pressed.

 

Button1.OnSelect: UpdateContext({ myColor: If(myColor = Color.Red, Color.Blue, Color.Red) })

You can also have an initial value for that variable, which would be normally set on the OnVisible property of the screen where the textbox and button are located:

 

Screen1.OnVisible: UpdateContext({ myColor: Color.Red }) 

 

View solution in original post

Obrigado Carlos! Smiley Happy

Hi, 

 

Thanks for your reply, it enlightes me.

 

What if I would try to set only the object selected inside of a vertical gallery?

 

Thank you

Helpful resources

Announcements
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

Top Solution Authors
Top Kudoed Authors
Users online (51,580)