Changes

XAML Best practices

3 bytes removed, 13:06, 3 December 2025
/* Performance analysis (Mobile only) {{Version/MobileSince|5.0}} */
In the Mobile app, {{UBIK}} provides customizers a possibility to analyze the performance of specific UI elements by measuring the time it takes to render them. This can help customizers find performance weak spots in the entire UI and also serve as a benchmarking tool to verify the result of any improvement attempts.
The measurement is achieved through the use of the MeasurePerformanceBehavior. The concept of it is very similar to other behaviors, namely you attach it to any UI element in the XAML code (as long as it's a derivate of the [https://learn.microsoft.com/en-us/dotnet/api/microsoft.maui.controls.visualelement?view=net-maui-9.0 VisualElement], which should cover the vast majority of all UI element types).
* The behavior measures the time to render the UI element (which it attaches to) as well as its child elements (recursively if any).** Note: The time measured for e.g UBIKChildArea doesn't include the render time for all UBIKChildItem's.
* You can attach multiple behaviors to multiple UI elements at the same time, one to each, in order to get the measurements of the different elements.
* The measurements are logged in the UBIKDebugUBIKUIRenderingPerformance.log file under the app's Logs folder.
* You can and should assign a unique name to the Label property of the behavior, so that it's easy to identify the render time of the target element.
With this, you should see log entries such as the following, one for every child item that you see when opening a content page.
<pre>2025.0712.15 1203 13:1239:18:1030 Debug Sender: MeasurePerformanceBehavior Message35:4747 | Grid 'Rendering MicrosoftUBIKChildITEM_RootGrid' rendered in 28.Maui.Controls.Grid UBIKChildItemRootGrid took 8.4889 3865 ms'</pre>
[[Category:Mobile|XAML Best practices]]
117
edits