==== Best Practices ====
* 🏆 A good rule of thumb is to '''always use the least complex control possible'''.
** For example, there is no need to use a Filter + ListView to show a single UBIK object or property. Instead, you can bind the specific context of that object or property to a xaml control, and everything nested inside will inherit that binding context. This will be explained more in the section on [[XAML_Best_practices#Reusable_Templates|Reusable Templates]].
** Similarly, simple EvalExpressions can in many cases be replaced with [[XAML_Best_practices#Converters|Converters]].
** The Visibility attribute can be added to any control. There is no need to wrap any control in a Grid simply to apply a Visibility. The same goes for layouting attributes such as Grid.Row/Column.
* 🏆 When you need to show a collection of items such as ListView, '''always use our custom versions'''. These are UBIK-optimized for speed and performance.** These are [[XAML_Tips#Version_3.7_.26_later|SelectionBoundListView ]] on UWP and [[Xamarin_XAML#SfListViewExt|SfListViewExt ]] on Xamarin.
** Avoid using other item controls, or BindableLayouts, unless you are sure the performance impact will be negligible.
* Layouts:
** If things need to be positioned relative to each other, use a StackPanel/StackLayout.
** When defining Rows/Columns for a Grid, assign as few Auto size as possible, and avoid putting controls of unlimited size in an Auto Row.
** 🏆 Controls '''Never nest controls of unrestricted size, such as ListView, should never be nested within controls of unlimited size, such as a StackPanel/StackLayout.'''*** To clarify: Some controls resize themselves based on their content and can be of unlimited size. One example is a StackPanel/StackLayout, when compared to a Grid, which is limited to the screen's size. On the other hand, some controls have an unrestricted size, such as ListView, ScrollView, etc.*** Furthermore: ListViews require a fixed size in order to preserve [[XAML_Best_practices#Virtualization|virtualization]].
* Do not nest ScrollViews within other ScrollViews.
** Note that this includes '''any''' control with scrolling behavior, as these include a hidden built-in ScrollView. For example, never place a ListView or TreeView within a ScrollView.
* Nested ListViews involves using a ListView on the item template of an object already presented in a collection. For example, showing the children of a child object.
** This is especially an issue in Xamarin, both for performance, but also because sfListViewExt tends to cause layouting issues by taking up more space than needed, unlike in UWP where a ListViewExt is capable of calculating its size based on the size of its items. Therefore, when using nested ListViews in Xamarin, constrain the size of the inner ListView with a fixed HeightRequest attribute (or WidthRequest in the case of a horizontal list).
** ⚠️ 🏆 '''Alternatives to the optimized ListViews (SelectionBoundListView on UWP and SfListViewExt on Xamarin), such as CollectionView or BindableLayout, should be used with extreme caution, .''' Controls such as these CollectionView or BindableLayout are not optimized for good performance in UBIK.