🚀 Welcome to MDriven Learn –  MDriven is now on Discord!  Don’t miss the latest Release Notes.
OCLOperators Styles
This page was created by Hans.karlsen on 2023-07-21. Last edited by Wikiadmin on 2026-07-29.

You can apply a named style from StylesInModel to a ViewModel UI element by using the Styles OCL/EAL operator in that element's Style Expression.

Purpose

Use Styles when you have defined a style in StylesInModel and want a Row, Column, Control, or placing container in a ViewModel to use it.

For example, if the Style Editor contains a style named Search, use the following expression to retrieve and apply that style:

selfVM.Styles.Search

Syntax

selfVM.Styles.StyleName
Part Meaning
selfVM The current ViewModel instance.
Styles Access to the styles defined in StylesInModel.
StyleName The name of the style to retrieve from the Style Editor. Replace this part with the name of your style.

Apply a style to a ViewModel element

  1. Define the style in StylesInModel by using the Style Editor. For this example, create or use a style named Search.
  2. Open the ViewModel Editor.
  3. Select the Row, Column, Control, or placing container that should use the style.
  4. Set its Style Expression to the expression that names the style:
selfVM.Styles.Search
  1. Save the ViewModel and render the UI. The selected element uses the properties defined by the Search style.

Example: reuse a search style

A ViewModel can use the same named style in more than one place. If Search is defined in StylesInModel, set the Style Expression on each relevant UI element to:

selfVM.Styles.Search

The expression returns the Style object named Search. The element where you set the Style Expression then renders according to that style's defined properties.

Notes

  • The name after selfVM.Styles. must identify a style defined in StylesInModel.
  • Use this expression in the Style Expression of the UI element that you want to style; it does not define the style itself.
  • To apply a different named style, replace Search with that style's name. For example, a style named Header is referenced as selfVM.Styles.Header.

See also