Displaying Text
You can display text in MCML using the Text view item, which allows you to specify fonts, colors, and additional text-related attributes such as whether to allow word wrapping. MCML supports RTF as multi-line formatted text in the Content field of a Text element.
Character and Entity References
To display characters that would otherwise be interpreted by the MCML parser as MCML code, use the following entity references in markup.
Character | Entity Reference |
< (less than) | < |
> (greater than) | > |
& (ampersand) | & |
' (apostrophe or single quote) | ' |
" (double quote) | " |
For example, the MCML code below displays the following string: Specify your <username>
<cor:String String="Specify your <username>"/>
Text Layout
To create space between text items, you can use the FlowLayout layout, margins, or insert a Panel view item with a minimum size as a spacer. The following example shows how to create a basic text display with different ways of spacing text. This example also shows how to set fonts at the top level of the document for use by multiple user interfaces (UIs).
<Mcml
xmlns="https://schemas.microsoft.com/2008/mcml"
xmlns:me="Me">
<Font Name="SmallFont" Font="Verdana,10" />
<Font Name="BigFont" FontName="Verdana" FontSize="18" FontStyle="Bold,Italic"/>
<UI Name="TextDisplay">
<!-- This UI displays the other UIs. -->
<Content>
<Panel>
<Layout>
<FlowLayout Orientation="Vertical" Spacing="50,0" />
</Layout>
<Children>
<me:TextSettings/>
<me:UsingMargins/>
<me:UsingColorfillWithText/>
</Children>
</Panel>
</Content>
</UI>
<UI Name="TextSettings">
<!-- This UI provides an example for the MaximumLines and WordWrap settings. -->
<Content>
<Panel Layout="VerticalFlow" MaximumSize="140,0">
<Children>
<Text BackColor="Gold" Font="font://me:BigFont" MaximumLines="3" WordWrap="true"
Content="This large text will wrap. This sentence won't be displayed because it exceeds the 3 line maximum." />
</Children>
</Panel>
</Content>
</UI>
<UI Name="UsingMargins">
<!-- This UI provides an example of using margins to create space between text items. -->
<Content>
<Panel Layout="VerticalFlow">
<Children>
<Text Color="Aquamarine" Font="font://me:SmallFont" Content="You can use margins to create space between text items:" />
<Text Margins="0,20,0,0" Color="SkyBlue" Font="font://me:SmallFont" Content="This sentence has a top margin of 20 pixels." />
</Children>
</Panel>
</Content>
</UI>
<UI Name="UsingColorfillWithText">
<!-- This UI provides an example of placing text inside a ColorFill view item. -->
<Content>
<ColorFill Content="GreenYellow" MinimumSize="500,40" >
<Children>
<Text HorizontalAlignment="Center" Color="Maroon" Font="font://me:SmallFont" Content="This text is placed in a ColorFill view item." />
</Children>
</ColorFill>
</Content>
</UI>
</Mcml>
Sample Explorer
- View Items – Text > all samples
See Also