Same way, we can set for ItemCount to calculate X and Y.
Now I set Height of the label according to the Template Size of the Gallery using below formula.
After all these formulas, my table looks like this.
Anything missing in this table??? Yes, you are correct. The header is missing.
Step 4 - So let’s create a Header.
To add a Header, we will need 4 labels outside the gallery. I rename it ProductId_Header to make it more readable.
Now, first I will set Its height as the TemplateHeight of the Gallery using the same formula we have used to set item labels’ height.
I want to set Background of these header labels to gray RGBA(166, 166, 166, 1) and font color to white RGBA(255, 255, 255, 1).
We should not set these colors manually for each label or each control as many times our clients may ask us to change the design. We would do it dynamically.
Create 2 variables in OnVisible event of the screen.
If you do not know more about Variables in PowerApps don’t worry
this site has all the explanations.
Now go to formula bar of each header label, select Fill Property and set HeaderBG variable; select Color property and set HeaderFont variable.
Then set X the same way we have X position for Item Labels, width same as item label width respective to the header and text of the label.
Now comes the last part the Y position. Logically we set header above our item label and our item label is inside our Gallery hence we will use X of the Gallery.
But we don’t want to overlap item labels and header labels. That means, we need to make sure to consider the height of the header label. So formula will be,
Finally, our table looks like this.
Summary
We can use dynamic styling of controls that can save us up to 80% time. Whenever we want to change anything in design, we just need to change the value of the variables.
Hope you found this blog useful.
Please comment your feedback in the comments section below.