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

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
Highlighted
Power Apps
Power Apps

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
Highlighted
Community Support
Community Support

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.
Highlighted
Microsoft
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.

 

 

 

 

 

Highlighted
Power Automate
Power Automate

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!

 

 

Highlighted
Power Apps
Power Apps

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

Highlighted
Power Automate
Power Automate

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 🙂

Highlighted
Power Automate
Power Automate

Re: Dynamic Image Name Question

That worked, and stopped the fluctuation! Thank you!

Helpful resources

Announcements
secondImage

New Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

Experience what’s next for Power Apps

Join us for an in-depth look at the new Power Apps features and capabilities at the free Microsoft Business Applications Launch Event.

Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (8,583)