cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
dantept
Level: Powered On

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 Staff CarlosFigueira
Power Apps Staff

Re: Changing another object property with a button/ image click

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

2 REPLIES 2
Power Apps Staff CarlosFigueira
Power Apps Staff

Re: Changing another object property with a button/ image click

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

dantept
Level: Powered On

Re: Changing another object property with a button/ image click

Obrigado Carlos! Smiley Happy

Helpful resources

Announcements
New Ranks and Rank Icons in April

'New Ranks and Rank Icons in April

Read the announcement for more information!

Better Together’ Contest Finalists Announced!

'Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

thirdimage

Community Summit North America

Innovate, Collaborate, Grow - The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (10,063)