cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
JHDavoli
New Member

Assigning control properties (Color, FontWeight, etc.) for the quickest UI rendering

To all:

 

I wonder if I am making a bad trade-off between design environment efficiency and production environment speed.

 

I am building a canvas app that requires dozens of fields, and my users do not like the Power Apps out-of-the-box colors, sizes, etc.  Since the Power Apps design environment offers no way to change en masse the properties of labels, textboxes, etc., I am compelled to tediously visit each and every control and assign it the same Color, Height, Size, FontWeight, etc. -- like raking a lawn with a salad fork.  I am changing those properties to match my users' expectations, but I can easily see someone asking if we can get that label Fill color in cornflower blue.

 

To increase my design environment flexibility, I created a standard Label, a standard Textbox, a standard Toggle, a standard Date Picker, etc. and visited every control, assigning properties to their corresponding "standard" control.  E.g.:  The "Size" property for each label in every single Data Card is set to lblStandard.Size; the "Color" property for each label is set to lblStandard.Color.

Then, from a Vishwas Lele video, I understood that variables would be quicker than references to other controls.  So I abandoned standard controls and instead created and assigned values to global variables as standards. E.g.:  Set( glbLabel, {Color: RGBA(0,0,0,100), FontWeight:FontWeight.Bold, Size: 10, etc.:etc.}), and assigning the "Size" property for each label to glbLabel.Size, and so on.  That way, when I receive the inevitable request for a change, I simply change the property in the global variable and voila!  The controls all change!

 

When I run the App, I suppose it runs just fine, but I wonder if it would run much, much faster if I altogether abandoned design efficiency and simply hard-coded property values.  That is, when the App loads, or when the Screen becomes visible, are dozens of labels, textboxes, etc. desperately assigning values to six or eight properties each and then rendering?  Any insights?

2 REPLIES 2
LRVinNC
Super User
Super User

Using relative styling (parent/child relationships) for properties settings is the best practice.  See page 26 of Power Apps canvas coding standard and guidelines for info on this topic and more in this white page of standard  guidelines for developing consistent, performant, and easily maintainable apps.  

LRVinNC

------------------
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.

Thank you for your reply. I am afraid that the White Paper does not hold the answer my question. Here is its guidance:

App design
Using parent/child relationships for relative styling
We recommend that you use one control’s style as the basis for styling other controls. In general, use relative styling for the color, fill, x, y, width, and height properties.

 

The Contoso Corporation address book, with five labels and five controls using relative styling, will unquestionably render instantly. My question is about a real-world application requiring dozens of fields and involving between six and eight property assignments that are each resolved client-side. In that scenario, is there a noticeable performance penalty for relative styling?

 

With ASP.NET, for example, the code is compiled and runs on the server, and the page is fully rendered before it arrives in the user's browser. From what I can glean, the Power Apps functions are built up from JavaScript libraries. Thus, it seems to me that the GUI arrives at the browser, and then the client-side JavaScript interpreter runs through all of the properties assignments, and then the user sees the result.

 

I am trying to determine if there is a performance penalty for using "relative styling" and, if so, how bad?

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,669)