Table of Contents

Class LocalizeExtension

Namespace
Icy.Markup.Extensions
Assembly
IcyUI.dll

{Localize Key}: the localized string for a key, in the configuration's Culture, updated when the culture changes.

[MarkupExtensionDefaultProperty("Key")]
public sealed class LocalizeExtension : IMarkupExtension
Inheritance
LocalizeExtension
Implements
Inherited Members
Extension Methods

Remarks

  • {Localize Menu.Play} is short for {Localize Key=Menu.Play}; Context= tells apart keys with the same text (gettext's msgctxt).
  • On a property that doesn't take text, such as Content, the string goes through the configuration's text converter, as a plain string attribute does: Content gets a TextBlock.
  • A missing key shows the key itself (see Localize(string, string?)).
  • In a style setter, the string is resolved once, when the style loads, and doesn't change with the culture: styles are shared by many elements. Templates are fine.

Properties

Context

Gets or sets an optional context for the key, or null.

public string? Context { get; set; }

Property Value

string

Key

Gets or sets the key, such as Menu.Play.

public string Key { get; set; }

Property Value

string

Methods

ProvideValue(MarkupExtensionContext)

Computes the value the loader should use.

public object? ProvideValue(MarkupExtensionContext context)

Parameters

context MarkupExtensionContext

The property being resolved, and what the loader knows about the document.

Returns

object

The value to assign, converted the same way an ordinary attribute value would be; or Unset when the extension already applied its own effect (typically by binding the property itself) and nothing further should be assigned.

Exceptions

MarkupException

No key is given, or the string can't be converted to the property's type.