cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Count elements in gallery / full gallery height in canvas

Hello,

 

I've created a gallery inside a canvas element. Each gallery element contains several elements to display. I want to calculate the sum of the height of all gallery items to set the number for the Height-Attribute of the gallery.

 

The gallery should be shown with full height and I want to use this inside a gallery element to add other items below the gallery.

 

Thank you

15 REPLIES 15
Mike8
Memorable Member
Memorable Member

Hello andrewichert,

You can add a label in your MyGallery. Let's name it LabelRecordSum.

Please set:
LabelRecordSum.Text= Label1.Height+Label2.Height+Label3.Height+Label4.Height
This label will show the sum of the labels' heights 

Now outside of your gallery create a label ---> LabelSum
LabelSum.Text=Sum(MyGallery.AllItems,LabelRecordSum.Text)

Now you can set:
LabelRecordSum.Visible=false and it's hidden from the user but still does what you need.

I hope it's good enough for you.

View solution in original post

Anonymous
Not applicable

Hi @Mike8,

 

thank you very much. This mostly achives my goals. Have to round up a little bit and add some more values. But your solution is what was needed.

 

Tanky you

Hey @Anonymous glad you got it working. Just out of curiosity did you try the flexible height gallery control? I didn't know about it until recently but I wonder if it does what you want on its own?

Shane - Microsoft MVP, YouTube, and PowerApps Consulting for when you are in a bind to get this fixed quickly. And finally we now have PowerApps Training
Anonymous
Not applicable

Hi @Shanescows, you mean "Blank flexible height"? Yes I'm aware of this and always using this, as it gives me the most control about my galleries. But it doesn't work as expected. Sometimes everything is fine but in most cases I've been using a nested gallery or every element has an autoheight attribute turned on (like labels) and this will broke most of the galleries.

 

I don't want to rely on this feature and use my own calculations to show the galleries properly.

Cool and thanks for the feedback. I just had never used it and thought I would get your insight on it. Thanks for sharing. 

Shane - Microsoft MVP, YouTube, and PowerApps Consulting for when you are in a bind to get this fixed quickly. And finally we now have PowerApps Training

Thank you so much for this solution. I have been working my butt on getting the galleries to not scroll within a scrolling canvas... saves my day!

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (2,695)