Showing results for 
Search instead for 
Did you mean: 
Not applicable

Make visible item in horizontal gallery the selected item.

I have a horizontal gallery that contains items from an inventory. Basically, I'm wanting the item that is visible on the screen to be the 'selected' item. Currently, the only way I can set this is to scroll to the item and then physically click the image of the visible item but i'm trying to skip this step.  Any ideas?



Power Apps Staff CarlosFigueira
Power Apps Staff

Re: Make visible item in horizontal gallery the selected item.

It is possible, but not too straightforward. The gallery has a property, VisibleIndex, which contains the index of the item that is being shown (*). And you can use a combination of the Last and FirstN functions to retrieve an item by the index from a collection. So the shown item in a gallery is accessible via the following formula:

Last(FirstN(Gallery1.AllItems, Gallery1.VisibleIndex))

So far, so good. The problem (the '*' I added above) is when multiple items are visible. Currently if this is the case the 'VisibleIndex' property will be the smallest of the indices, and that can lead to some weird behaviors. For example, in the app shown below, the label under the gallery is listing the title of the "visible" item:


The item that is being shown the most is the fourth item (Lorem ipsum 4), but since part of the third item is still visible, that's the one that is being reported.


If you want to use this in your app, you'll need to ensure that the template size of the gallery is the same width of the gallery, otherwise it would be impossible for the last item to be completely visible by itself. And it would be good to have some visual indication to the user of which item they are selecting (for example, in your case the button text could be "Loan & Record Wired Mouse")


Try it out; if you believe that the 'visible index' logic should be changed (or configured by some additional property), please consider creating a new feature request in the PowerApps Ideas board.

Helpful resources


Power Apps Community User Group Member Badge

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


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


Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Kudoed Authors (Last 30 Days)
Users online (3,832)