Show / Hide Table of Contents

Method CheckListDialog.FormatText


Overload

Sets formatted text, like wpfBuilder.FormatText.

public void FormatText(wpfBuilder.InterpolatedString text)
Parameters
text  (wpfBuilder.InterpolatedString)

Interpolated string (like $"string") with tags etc. The format is XML without root element.

These tags add inlines of these types:

  • <b>text</b> - Bold.
  • <i>text</i> - Italic.
  • <u>text</u> - Underline.
  • <s>text</s> - Span.
  • <s {Span}>text</s> - Span or a Span-based type. The function adds text to its Inlines collection.
  • <a {Action or Action<Hyperlink>}>text</a> - Hyperlink that calls the action.
  • <a href='URL or path etc'>text</a> - Hyperlink that calls run.itSafe.

Tags can have these attributes, like <s c='red' FontSize = '20'>text</s>:

  • c or Foreground - text color, like 'red' or '#AARRGGBB' or '#RRGGBB' or '#ARGB' or '#RGB'.
  • b or Background - background color.
  • FontFamily - font name, like 'Consolas'.
  • FontSize - font size, like '20'.
  • ToolTip - tooltip text.

WPF elements of these types can be inserted without tags:

  • {Inline} - any inline, eg Run. See also <s {Span}>text</s>.
  • {UIElement} - a WPF element, eg CheckBox or Image.
  • {ImageSource} - adds Image.
  • {IEnumerable<Inline>} - adds multiple Inline.

XML special characters must be escaped:

  • < - &lt;.
  • & - &amp;.
  • ', " - &apos; in 'attribute' or &quot; in "attribute".

The text in above examples can contain nested tags and elements. The <a> tag creates an image hyperlink if text is {image}, where image is a UIElement with image (see ImageUtil.LoadWpfImageElement) or ImageSource (see ImageUtil.LoadWpfImage, icon.ToWpfImage).

Exceptions
NotSupportedException

Unsupported obj type or non-empty Content/Header.

ArgumentException

Unknown <tag> or unsupported {object} type.

InvalidOperationException

The same {Span} or {Inline} object in multiple places.

FormatException

Invalid color attribute.

Exception

Exceptions of System.Xml.Linq.XElement.Parse.