cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Slaverty
Advocate III
Advocate III

Possible bug with Gallery reading properties of controls within

Hi,

Having trouble getting a nested gallery to read properties of its controls within.  Anyone know if this is a bug/by design/user error?

 

To expand, I have a gallery (Main_Gallery) with a gallery (Sub_Gallery) inside it.  

I'm trying to get the Sub Gallery to dynamically wrap depending on the width of the text labels (eg SG_TextLbl) within, but the Gallery is unable to read the width/height/text properties of those items.  Even if I simply put 

Sub_Gallery.Height = SG_TextLbl.Height

The formula results preview then displays "SG_TextLbl.Height =   |  Data Type: Number" and the gallery has 0 height.

Even tried setting the .Text value of SG_TextLbl to it's own height, Gallery couldn't read that either.

4 REPLIES 4
WarrenBelz
Super User
Super User

Hi @Slaverty ,

May be a silly question, but are you using a standard gallery or a Flexible Height item?

If the standard item, here is a video on creating Flexible Height items.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

I thought the "Flexible" in "Flexible Height Gallery" relates only to flexible template sizes, rather than the size of the whole gallery?

 

In any case, I created 2 new flexible height galleries containing just a single Label each, one gallery nested within the other.  The results lead me to believe this is a bug.  Initially, the parent gallery could read the label's width, but not the height, both were defined absolutely (70 and 50 respectively). 

I then tried replacing the labels width and height with formulas, after which the gallery couldn't read either. 

I then put the label's width and height back to defined values (70 and 50 respectively), but the parent Gallery was still unable to read either.

I then checked some other properties, seeing what the gallery could read, and it read the Padding, LineHeight, Size, BorderThickness properties fine, so I switched back to Width and now that worked again, but height still isn't.

 

EDIT

After a little more playing around, discovered something even weirder.  

If Label.Height = 70,

And Label.Width = Label.Height,

And Gallery.Height = Label.Width

Gallery.Height becomes 0, formula preview indicated "Label.Width =  |  Data Type: Number"

but

If Label.Width = 70,

And Label.Height = Label.Width,

And Gallery.Height = Label.Height

Gallery.Height now = 70.

So definitely something weird going on with the parent gallery reading the child's height property

WarrenBelz
Super User
Super User

Hi @Slaverty ,

Yes you are right about the template in these galleries.
I am not sure if this helps, but I can share some experience I have had on “cascading” dependencies of control values, mine were about colour attributes, but the principle is the same.

Once I got beyond three levels and did a variable-driven change, it did not always reach the “end of the line”. You are taking about a different component of course, but it has more work, moving things around the screen. 
I recently watched a couple of good videos on your subject from Paul O’Flaherty

Group by and flexible height

Expand and collapse

You might find a solution in these.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Thanks @WarrenBelz, that's some very useful info. I'll give those vids a watch too for sure. I did also wonder if it had something to do with the fact that I was referencing a gallery controls height, a gallery control which obviously had many occurrences, and so maybe the gallery had no idea which label instance's height to choose from?

I did manage to implement a workaround though, albeit a bit of a dirty one. Basically put a timer in the gallery, timer starts when visible, has a timer value of 0ms, and when complete, fires the label's width into a variable. Gallery then works off variable. It's not pretty but does the job

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (1,635)