Jump to: navigation, search

Changes


XAML Best practices

223 bytes removed, 25 July
Restructured templating into a new section (ToC tree was too deep)
* More xamls also makes it more difficult for others to read and understand the customizing. This also makes it much more difficult to find and diagnose errors when requesting support. It also generally increases the effort required to maintain the xamls.
<br>
 
Check out the next section for a more in-depth look into [[XAML_Best_practices#Templating|Content Templating]].
==== Best Practices ====
** Remove files for child Areas and Items that are not included in this project.
<br>
 
==== Template Selectors ====
Although you can always hardcode what template to use, sometimes a more dynamic template selection is required. For example, think of the ChildItemTemplateSelector used in the generic UBIKChildArea. A more advanced example is found on the UBIKPropertyDirectItemContainer, which defines all the common aspects of a Property Item in UBIK 4.0+, but then uses the PropertyDirectItemTemplateSelector to swap in the relevant type-based user input controls (such as textbox, selection, datetime, geo coordinates, etc).
 
The logical tree used by these selectors to render different UIs is documented in our article [[UBIK_Templates]].
<br><br>
 
[[Category:Pages with broken file links|XAML Best practices]]
[[Category:XAML|XAML Best practices]]
=== How to select the right Control ===
Attributes are the properties used to customize the controls in a UI. The number of attributes on each control can also contribute to having 'too much' code. Reducing the number of attributes will improve the overall performance of a customizing, especially on elements that appear multiple times in the UI,s such as items in a list.
[[XAML_Best_practices#Templating|Custom templates ]] can be used with the additional benefits of defining a uniform look for all similar elements, and reducing customizing effort by creating a central point where a reusable template can be maintained.
==== Best Practices ====
** DataTemplates and ControlTemplates are reusable XAML elements that can be defined once and applied several times throughout the customizing.
** You may have noticed that a DataTemplate is the basis for an item template in UBIKThemes. However, these can be applied anywhere in the xaml, and do not require a ListView to be rendered.
** For more information, read the section on [[XAML_Best_practices#Content_TemplatingTemplating|Content Templating]] below.
* 🏆 '''Reduce the number of elements, especially containers''', wherever possible.
** Layouts are often defined in multiple nested containers, usually Grids and StackPanels. This has an impact on performance if it leads to a very deep hierarchy of rendered elements. On mobile devices with less computational power, the difference can be felt.
<br>
[[Category:Pages with broken file links|XAML Best practices]]
[[Category:XAML|XAML Best practices]]
==== Content Templating ====Similar to styling single controls, presets featuring groups of controls can also be defined in UBIKThemes and used anywhere in the client.The benefit of this
One simple example of this is an ItemTemplate. Project customizers should be familiar with ItemTemplates, which are defined in UBIKThemes and then applied to every item in a List, for example. However, such templates are not inherently connected to listviews, and can be used on any items control, or can even on its their own, if the situation calls for it. The important thing to understand is that a content template is a standalone unit, defined in xaml to display particular data bindings, and perhaps react to various states.
{{Hint|Look at other interesting templates in UBIKThemes, such as "Badge" / "ChildCountBadge" in Xamarin, or "UBIKObjectIndicators" in UWP to see more ideas for how templates can be utilized.}}
 
===== DataTemplate vs. ControlTemplate =====
 
 
 
 
==== Template Selectors ====
Various parts of the UBIK UI are dynamically swapped in based on specific conditions. One example is the UBIKPropertyDirectItemContainer.xaml, which serves as the base for an item in the property list, and which renders a different type-appropriate editing UI for each kind of property input (such as textbox, selection, datetime, geo coordinates, etc).
 
The logical tree used by these selectors to render different UIs is documented in our article [[UBIK_Templates]].
<br><br>
 
 
 
 
{{UnderConstructionEnd}}
[[Category:Pages with broken file links|XAML Best practices]][[Category:XAML|XAML Best practices]]
== Performance ==
511
edits