Xamarin.Forms Guides | Samples


Defines the interface for Xamarin.Forms XAML markup extensions.

See Also: IMarkupExtension


public interface IMarkupExtension


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}"/>


Namespace: Xamarin.Forms.Xaml
Assembly: Xamarin.Forms.Core (in Xamarin.Forms.Core.dll)
Assembly Versions:,,,,,,

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

Public Methods

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