Xamarin.Forms Guides | Samples

Xamarin.Forms.Xaml.IMarkupExtension

Defines the interface for Xamarin.Forms XAML markup extensions.

See Also: IMarkupExtension

Syntax

public interface IMarkupExtension

Remarks

Types implementing this interface can be used as custom XAML markup extension.

The following example shows declaration of a custom markup extension.

C# Example

public class ColorMarkup : IMarkupExtension
{
  public int R { get; set; }
  public int G { get; set; }
  public int B { get; set; }

  public object ProvideValue (IServiceProvider serviceProvider)
  {
    return Color.FromRgb (R, G, B);
  }
}
The markup extension can be used directly in XAML

XAML Example

<Label TextColor="{localns:ColorMarkup R=100, G=80, B=60}"/>

Requirements

Namespace: Xamarin.Forms.Xaml
Assembly: Xamarin.Forms.Core (in Xamarin.Forms.Core.dll)
Assembly Versions: 1.0.0.0, 1.1.0.0, 1.2.0.0, 1.3.0.0, 1.4.0.0, 1.5.0.0, 2.0.0.0

The members of Xamarin.Forms.Xaml.IMarkupExtension are listed below.

Public Methods

ProvideValue(IServiceProvider) : Object
Returns the object created from the markup extension.