Hello,
I am successfully using Parent.Size on several objects to change the font size depending on the screen size, as shown here:
https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/create-responsive-layout
Parent.Width *
Switch(Parent.Size,
ScreenSize.Small, 0.5,
ScreenSize.Medium, 0.3,
0.25)
I am now trying to achieve the same thing within a gallery, when the screen size is set to ScreenSize.ExtraLarge update the font size to something a bit bigger.
The problem I run into is now I am in a gallery Parent is something else so Parent.Size no longer works. I've looked under App. and Screen. for something similar but can't find what I want.
How can I get around this?
Thanks in advance
Solved! Go to Solution.
You can get to that with App.ActiveScreen.Size
App.ActiveScreen.Width *
Switch(App.ActiveScreen.Size,
ScreenSize.Small, 0.5,
ScreenSize.Medium, 0.3,
0.25)
I hope this is helpful for you.
You can get to that with App.ActiveScreen.Size
App.ActiveScreen.Width *
Switch(App.ActiveScreen.Size,
ScreenSize.Small, 0.5,
ScreenSize.Medium, 0.3,
0.25)
I hope this is helpful for you.
Thanks for the quick reply.
I've tried App.ActiveScreen.Size in a label so can confirm it works and updates at the same time as Parent.Size however the font sizes in my gallery don't seem to be changing while using it.
I'm using a slightly different formula to the example however this is working outside the gallery. Maybe it is to do with the gallery?
Switch(
App.ActiveScreen.Size,
ScreenSize.ExtraLarge,
14,
11)
It shouldn't be an issue. That value would be the same in or out of a Gallery.
If you want to confirm this, put a label in your Gallery and set its text to App.ActiveScreen.Size and see if it responds as you expect.
If so, then I would review your font size formulas again and I would assume you also would be resizing the entire Gallery based on the screen size?
I have tried putting a label in my gallery and set it's text to App.ActiveScreen.Size and the label doesn't update when I resize the screen. (A label outside the gallery is updating as expected).
Any other ideas? 🤔
Yeah, the whole gallery is set to resize based on the screen size. This bit responds as expected.
Hmmm, I would not have expected that!
Well, in that case - use the label!
If the label outside of the Gallery responds properly, then just reference that.
ex. lblSize text property : App.ActiveScreen.Size
in the Gallery - Value(lblSize.Text)
I think the issue is actually with App.ActiveScreen.Size.
When I tested it in a label outside of the gallery it was actually part of a bigger label I was using:
"Height: " & App.Height & " Width: " & App.Width & " ParentSize: " & Parent.Size & " ActiveScreenSize: " & App.ActiveScreen.Size
I think having other properties updating allowed App.ActiveScreen.Size to update.
I just tried to create a label for App.ActiveScreen.Size on it's own (Outside of the gallery) to try your suggestion and it didn't update when I resized the screen. (which would be why it didn't work in the gallery!)
If instead I create a label outside the gallery with Parent.Size I can reference this within the gallery just fine and it updates OK.
Not sure if that was by design or a bug somewhere!
Thanks for all your help!
Yep, that was where I was going next...just use Parent.Size in the outer label.
Glad you got to it.
User | Count |
---|---|
232 | |
109 | |
94 | |
59 | |
29 |
User | Count |
---|---|
293 | |
126 | |
106 | |
62 | |
57 |