Table of Contents

Class Translate

Namespace
Tlumach.MAUI
Assembly
Tlumach.MAUI.dll

A XAML markup extension that binds a bindable property to the text of a translation unit and updates the property when the culture of the unit's translation manager changes or when NotifyPlaceholdersUpdated() is called.

Usage: Text="{tlumach:Translate {x:Static translations:Strings.Hello}}", or, with a unit that comes from a binding, Text="{tlumach:Translate {Binding MyTranslationUnit}}" or Text="{tlumach:Translate Unit={Binding MyTranslationUnit}}".

The extension does not keep the target alive: the translation manager and the units, which the generated classes keep in static properties, reference it weakly.

[ContentProperty("Unit")]
[AcceptEmptyServiceProvider]
public sealed class Translate : IMarkupExtension<BindingBase>, IMarkupExtension
Inheritance
Translate
Implements
Inherited Members

Properties

Unit

Gets or sets the source of the text: either a TranslationUnit or a binding (BindingBase) whose value is a TranslationUnit.

A binding is resolved for the target element, so it can take the unit from the BindingContext, from a relative source, from a referenced element, or from an explicit source, also in data templates and style setters.

A value of any other type is treated as no unit, and the target property receives an empty string.

public object? Unit { get; set; }

Property Value

object

Methods

ProvideValue(IServiceProvider)

Creates a one-way binding of the target property to the current text of Unit.

public BindingBase ProvideValue(IServiceProvider serviceProvider)

Parameters

serviceProvider IServiceProvider

The service provider of the XAML parser. It is not used.

Returns

BindingBase

The binding to apply to the target property.