cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Jason_Hough
Resolver I
Resolver I

Date OnSelect make a label visible

All,

 

I have a gallery on the left hand side and when someone presses a button outside of the gallery - I want an label to become visible on the gallery. But only on the gallery item that was selected. 

 

I can find Gallery1.selected , but I tried to update the context on that. I added a variable to the visible object. This doesnt seem to work. 

 

Any ideas - just to make a label visible on the selected gallery item. 

 

Thanks, Jason. 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

To simplify if you need to add more and more galleies, try the reverse.

  • Create a global variable to cross screens on the first screen's OnStart: UpdateContext:({Gallery1LabelVisible:false})
  • For the screen with the gallery button or label. Edit the OnVisible: UpdateContext:({Gallery1LabelVisible:false}). ( Assuming you want the Galley and the external button on the same screen. If they are on different screens, you will have to remove that OnVisible code.
  • For the button or Label outside of the gallery. Edit the Text field to: If(Gallery1LabelVisible=false,"Gallery item UnSelected","Galley item Selected") etc. To trigger the label in the gallery If(Gallery1LabelVisible=false, UpdateContext:({Gallery1LabelVisible:true}),UpdateContext:({Gallery1LabelVisible:false}). Now if you click the external button, and then a gallery item, text will appear.
  • For the button that you can add in the galley. Go for full width with Parent.Width. Then you can use that as a label and a button. For its Text field: if(ThisItem.IsSelected&&Gallery1Label=true,"IsSelected text","IsUnSelected text"). Then go for the OnSelect: If(Gallery1LabelVisible=false, UpdateContext:({Gallery1LabelVisible:true}),UpdateContext:({Gallery1LabelVisible:false}). To toggle this effect add the same code that you used on the external button. OnSelect: If(Gallery1LabelVisible=false, UpdateContext:({Gallery1LabelVisible:true}),UpdateContext:({Gallery1LabelVisible:false})

That will do somethign like the following.

If an item in the galley is not selected It will present false text on a label anywhere due to a global variable.

If an item in the gallery is selected the text in both the gallery and the external label will produce true text.

 

Some things to think about.

Galleries depending on your filter rules and the default rule will always have something selected.

If you are using multiple screens you need a global variable.

You can have a toggle efeect.

You can create a simple variable instead of multple UpdateContext for each item. Then add if statements on the controls. For example: Visible: If(GlobalVariable=true,true,false). Size: If(GlobalVariable=true,21,16) X or Y: If(GlobalVariable=true,88,400)

View solution in original post

5 REPLIES 5
v-micsh-msft
Community Support
Community Support

Hi @Jason_Hough,

 

We could achieve it by changing the formula under the Visible property of the Label in the gallery as below:

If(BrowseGallery1.Selected.ID=ThisItem.ID&&Variable1=true,true,false)

Then under the Button OnSelect property, copy and paste the code below:

UpdateContext({Variable1:true})

Once button has been pressed, the Label would be shown only when the item has been selected from the Gallery.

Regards,

Michael

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
nickduxfield
Responsive Resident
Responsive Resident

Add the image in the ediable area of the gallery card. Add some code to the "Visible" control fields of the related items.

If(ThisItem.IsSelected,'Image',false). You may add other images. To have a label pop outside of the gallery, try a variable.

If(ThisItem.IsSelected,UpdateContext({PopupLabel:false,GalleryImage:true}),updateContext({PopupLabel:true,GalleryImage:false}))

You need to now put the variable in the popuplabel's visible control fields after you get the code setup otherwise everything will disappear. If that happens, delete all the code and set all 'Visible' cards images and labels 'true'.

This works correctly but I want the 'visible' to remain when the user presses another gallery item. I dont want it to disapear and another one shows, i want them both to show. Any ideas ? Thanks in Advance.

To simplify if you need to add more and more galleies, try the reverse.

  • Create a global variable to cross screens on the first screen's OnStart: UpdateContext:({Gallery1LabelVisible:false})
  • For the screen with the gallery button or label. Edit the OnVisible: UpdateContext:({Gallery1LabelVisible:false}). ( Assuming you want the Galley and the external button on the same screen. If they are on different screens, you will have to remove that OnVisible code.
  • For the button or Label outside of the gallery. Edit the Text field to: If(Gallery1LabelVisible=false,"Gallery item UnSelected","Galley item Selected") etc. To trigger the label in the gallery If(Gallery1LabelVisible=false, UpdateContext:({Gallery1LabelVisible:true}),UpdateContext:({Gallery1LabelVisible:false}). Now if you click the external button, and then a gallery item, text will appear.
  • For the button that you can add in the galley. Go for full width with Parent.Width. Then you can use that as a label and a button. For its Text field: if(ThisItem.IsSelected&&Gallery1Label=true,"IsSelected text","IsUnSelected text"). Then go for the OnSelect: If(Gallery1LabelVisible=false, UpdateContext:({Gallery1LabelVisible:true}),UpdateContext:({Gallery1LabelVisible:false}). To toggle this effect add the same code that you used on the external button. OnSelect: If(Gallery1LabelVisible=false, UpdateContext:({Gallery1LabelVisible:true}),UpdateContext:({Gallery1LabelVisible:false})

That will do somethign like the following.

If an item in the galley is not selected It will present false text on a label anywhere due to a global variable.

If an item in the gallery is selected the text in both the gallery and the external label will produce true text.

 

Some things to think about.

Galleries depending on your filter rules and the default rule will always have something selected.

If you are using multiple screens you need a global variable.

You can have a toggle efeect.

You can create a simple variable instead of multple UpdateContext for each item. Then add if statements on the controls. For example: Visible: If(GlobalVariable=true,true,false). Size: If(GlobalVariable=true,21,16) X or Y: If(GlobalVariable=true,88,400)

View solution in original post

XT2
Frequent Visitor

Quetion.PNG

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Don't miss the call this month on June 16th - 8a PDT

Top Solution Authors
Top Kudoed Authors
Users online (44,472)