Setting UI Properties

The Properties attribute of a UI allows you to parameterize a UI with properties, each of which consists of a type, a name, and a default value, thus allowing you to customize the UI. A property can be any MCML or user-defined type. Property default values are shared among all instances of the UI. These values are public and can be overridden. In the following example, the Properties attribute defines default values for the Color and Font attributes of a Text element:

  <UI Name="UsingProperties">
    <Properties>
      <Color Name="Foreground" Color="Blue" />
      <Font Name="DocFont" Font="Verdana,22" />
    </Properties>

    <Content>
      <Text Content="Using Font and Color properties" Font="[DocFont]" Color="[Foreground]" />
    </Content>
  </UI>

You can require the parent UI to supply a value for any property by marking it as "$Required", and an error will occur if that property is not specified. The following example requires the parent UI to define a Label string:

  <UI Name="MainDisplay" BaseUI="me:LabelProperties">
    <Content>
        <me:LabelProperties Label="A Label string is required." />
    </Content>
  </UI>

  <UI Name="LabelProperties">
    <Properties>
      <cor:String Name="Label" String="$Required" />
      <Color Name="ForeColor" Color="Red" />
    </Properties>

    <Content>
      <Text Name="Display" Content="[Label]" Color="[ForeColor]" Font="Arial,20" />
    </Content>
  </UI>

Note   Only reference types (such as classes) can be marked as $Required. Value types, such as structures or types, cannot be marked as $Required.

Any property that you define in the Properties block is saved when you navigate away from the page. When returning to the page, these properties are restored.

Sample Explorer

  • Markup > Properties

See Also