cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Power Automate Staff audrieg
Power Automate Staff

Dynamic Image Name Question

I have uploaded three images to my Power App (content>media).

ImageA

ImageB

ImageC

 

I have added three buttons to a new screen:

Button 1-A

Button 2-B

Button 3-C

I have added an image control (MyImage) under the buttons.

 

I want to click on the button and make the image change in the image control.

 

So, what I did is created a context value called "SImage" and I'm using it like this:

Button 1-A OnSelect = UpdateContext( { SImage: "ImageA" } )

Button 2-B OnSelect = UpdateContext( { SImage: "ImageB" } )

Button 3-C OnSelect = UpdateContext( { SImage: "ImageC" } )

 

Finally, I added a Textbox Control (IName).

I have set the textbox Name default value to SImage

I have set MyImage Image setting to IName.Text

(because in real life I need this to work even if the user changes screens)

 

When I click on the button the Textbox contents changes as expected, but the image does not show up at all. Can anyone help me out please?

1 ACCEPTED SOLUTION

Accepted Solutions
PowerApps Staff rgruian
PowerApps Staff

Re: Dynamic Image Name Question

Audrie,

 

 

PowerApps keeps no explicit mapping/association between the names of image resources and their underlying "values" that are referenced in formulas. You will need to maintain that mapping yourself:

 

    Button 1-A OnSelect = UpdateContext( { SImage: "ImageA", Image: ImageA } )

    Button 2-B OnSelect = UpdateContext( { SImage: "ImageB", Image: ImageB } )

    Button 3-C OnSelect = UpdateContext( { SImage: "ImageC", Image: ImageC } )

 

    IName.Text = SImage

    MyImage.Image = Image

 

I hope this helps.

 

 

Radu Gruian [MSFT] ** PowerApps Staff

View solution in original post

6 REPLIES 6
Community Support Team
Community Support Team

Re: Dynamic Image Name Question

Hi Audrieg,

 

Per my test, if I set the OnSelect property of the button as “UpdateContext( { SImage: ImageA } )” without a double quotation mark on ImageA, it would work.

 

Please try if this works for you.

 

Best regards,
Mabel Mao

Community Support Team _ Mabel Mao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Microsoft petsa
Microsoft

Re: Dynamic Image Name Question

Having almost the same problem ...
I would like to get the images from URL's instead and change them the same way dynamically in event handlers but could not get it to work for some reason.

 

Small test:

on Form "onVisible": UpdateContext( { myimage: "https://3.bp.blogspot.com/-W__wiaHUjwI/Vt3Grd8df0I/AAAAAAAAA78/7xqUNj8ujtY/s1600/image02.png" } ) 

 

then on the the actual image control I set property: Image=myimage

=> No visible picture.

 

Then when I use buttons to do the same this , still no image.

There must a be some syntactical trick to this, right ?

 

petri.

 

 

 

 

 

Power Automate Staff audrieg
Power Automate Staff

Re: Dynamic Image Name Question

My scenariio completely changed after I updated power apps. The image is working now (the returned value is now a link to the image embedded in the file). However the text value I wanted to be clean for the topic selection is now not working.

 

Thank you for your help with the picture though!

 

 

PowerApps Staff rgruian
PowerApps Staff

Re: Dynamic Image Name Question

Audrie,

 

 

PowerApps keeps no explicit mapping/association between the names of image resources and their underlying "values" that are referenced in formulas. You will need to maintain that mapping yourself:

 

    Button 1-A OnSelect = UpdateContext( { SImage: "ImageA", Image: ImageA } )

    Button 2-B OnSelect = UpdateContext( { SImage: "ImageB", Image: ImageB } )

    Button 3-C OnSelect = UpdateContext( { SImage: "ImageC", Image: ImageC } )

 

    IName.Text = SImage

    MyImage.Image = Image

 

I hope this helps.

 

 

Radu Gruian [MSFT] ** PowerApps Staff

View solution in original post

Power Automate Staff audrieg
Power Automate Staff

Re: Dynamic Image Name Question

I've got this really weird situation where the returned value for the Topic is fluctuating.....

 

I'm going to try what you suggested before I spend a lot of time explaining what I mean 🙂

Power Automate Staff audrieg
Power Automate Staff

Re: Dynamic Image Name Question

That worked, and stopped the fluctuation! Thank you!

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors (Last 30 Days)
Users online (4,717)