web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Dynamically set height...
Power Apps
Unanswered

Dynamically set height of flexible gallery in powerapps.

(0) ShareShare
ReportReport
Posted on by 41

I have a flexible height gallery where the row size of every item is different. I wish to not use the inner scroll and adjust the height of gallery according to the items in it and just use the screen scroll. I tried setting gallery height as (no. of items in gallery * y coordinate of seperator  + some value for space) but the thing is it will take y coordinate according to 1st item only but what if that is long or short in some cases. So it doesn't work as expected. 

 

Thanks in advance.

Categories:
I have the same question (0)
  • zmansuri Profile Picture
    6,048 Super User 2024 Season 1 on at

    Use TemplateSize property.

    Take dynamic height of each control in your gallery and set template height accordingly. So you won't see inside scroll but it will change the template's height according to data

  • User3336 Profile Picture
    41 on at

    I am using a flexible height gallery with auto height labels inside it. So the height of each row is different when we run the app. It won't work, I tried.

  • jblomberg Profile Picture
    86 on at

    I was looking for the answer to this exact same question. It'd be great if anyone knows how to fix this!

  • Ciso_Lima Profile Picture
    10 on at

    Hi Riya,

     

    I came across the same challenge as you and I think I have a solution!


    To be sure, let's confirm the challenge: Define the height of a gallery based on the variable heights of its lines (items).

    As your lines (items) have variable heights we can't just follow @zmansuri 's suggestion: count the number of lines (items) and multiply by a standard height. That wouldn't work.


    What we need to do is (1) identify the height of each row (item) individually and from that (2) define the height of the gallery. Lets go!

     

    Imagine this gallery:
    - glr_Quiz (flexible height gallery)
    ----- lbl_Question ( control label ) AutoHeight: true; X: 0; Y: 0;
    ----- lbl_Answer ( control label ) AutoHeight: true; X: 0; Y: lbl_Question.Height;


    1 ) Identify the height of each line (item):
    I noticed that glr_Quiz.AllItems also points to the controls that make up the gallery lines (Ex.: glr_Quiz.AllItems.lbl_Question), however, there are few properties that we have access to (Ex.: .Text) and Height, a property that We would like it so much, it's not one of them...
    That's when I got around the situation as follows - I added a label to the gallery that calculates the height of the line (item) in the Text field:


    ----- lbl_varItemHeight ( control label ) X: 0; Y: 0; Visible: false;

     

    And in the Text field:

     

    lbl_Question.Height + lbl_Answer.Height

     


    Ready! we already have the height of each row (item)!

     

    2) Set gallery height:
    - Now it's easy! In glr_Quiz.Height:

     

    //Sum of all different row heights
    Sum(Self.AllItems.lbl_varItemHeight, lbl_varItemHeight.Text)
    //Sum of all padding
    +((CountRows(Self.AllItems)+1)*Self.TemplatePadding)

     

     

    Now we have a flexible gallery that adapts its total height according to your variable height items!!! 

     

    Hope this helps.
    If it helped you, please comment.
    If you have a better idea, please comment too 🙂

     

    Obs.: Sorry for my English...

  • ldreith Profile Picture
    7 on at

    You are an absolute lifesaver!!

  • RathwynAE Profile Picture
    56 on at

    This almost but doesn't quite work for me - there's still some miniscule scroll in some (but not all) of the embedded galleries. No idea why, this seems like it should work no problem...

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 431

#2
WarrenBelz Profile Picture

WarrenBelz 360 Most Valuable Professional

#3
Kalathiya Profile Picture

Kalathiya 280 Super User 2026 Season 1

Last 30 days Overall leaderboard