Jump to: navigation, search

UBIK Templates


Revision as of 08:10, 18 November 2019 by LGE (Talk | contribs)

The UI of UBIK® WinX/UWP client is highly customizable. Project engineers/customizers can tailor the UI for minor style changes or major redesigns according to their needs.

General knowledge

Due to the nature of customizing, it's impossible to cover all issues or questions that one might have during customizing. However, the fundamental ones should become self explanatory with the help of the Developer Mode feature. Such questions include and are not limited to:

  • Which parts of the UI are customizable?
  • How do I get the default XAML templates used in the clients?
  • What kind of data can I present in the custom UI?
  • Where should I deploy the custom template files?

UI controls

Controls are basic building blocks for constructing the UI. Several types of them are used in the client.

Standard controls

All standard Universal Windows Platform (UWP) controls can be used for our WinX/UWP client. There are online official documentations available for these controls. Some official or 3rd party apps showcasing these also exist and can be of great help. For example, XAML controls gallery presents a rich collection of examples/tutorials.

3rd party and UBIK controls

We also use a few 3rd party (e.g. Syncfusion) and UBIK® custom made controls in our client. There is currently no compiled lists of such controls. However, as a general rule, any such controls one finds in the default templates can be used in customizings.

Template loading mechanism

Templates with default names

As one can see in the Developer Mode, the default client UI consists of many parts and each of them is defined in an individual template with names such as UBIKChildArea. When a custom template file with the same name is deployed, that template is used by the client instead of the default one that comes with the client.

Templates with custom names

A common problem with customizing templates such as UBIKChildArea is that it alters the UI for all types of child objects. In order to use different templates depending on the objects, solutions such as child area template classification and child item template classification are provided. Custom template files with names such as UBIKChildArea_WorkPackage can be deployed so that only objects of that type display the custom content while the rest still uses the default UI.

Other than the necessary server side data configuration, a template selector is also needed to achieve this. For example, here's the code snippet in the default UBIKContentArea template.

...
<Grid xmlns:tpl="using:UBIK.WinX.Templates">
    <Grid.Resources>
        <tpl:ChildAreaTemplateSelector x:Key="ChildAreaTemplateSelector" />
    </Grid.Resources>
    <ContentControl ContentTemplateSelector="{StaticResource ChildAreaTemplateSelector}" />
</Grid>
...

The child area template selector used in this example determines the child area template to use based on the following rules.

  • If an object defines a child area template name (see child area template classification), return the custom template with that name;
  • If not found and the "Strict Template Loading Policy" setting is turned on, returns an error template; (This can be useful for checking if some templates are missing before the final deployment.)
  • If not found, returns the default UBIKChildArea template.
IC Hint square.pngIt's possible to use a different syntax to refer to a custom named template, e.g.
<ContentControl ContentTemplate="{Binding TemplateService[UBIKChildArea_WorkPackage]}" /> .
However, since the client does not know which default template should be used, an error template will be used if the custom named one can not be found.
IC Hint square.pngIt's also possible to specify a Suffix for the template selector, e.g.
<tpl:ChildAreaTemplateSelector x:Key="ChildAreaTemplateSelector" Suffix="Small" />.
Unlike the custom name template name lookup, the Suffix is no longer considered optional once specified. If such a template file cannot be found, an error template will be used.