Skip to content

Instantly share code, notes, and snippets.

@codemillmatt
Created July 10, 2017 11:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codemillmatt/6b24c15cbf231221f0f13239e42becfe to your computer and use it in GitHub Desktop.
Save codemillmatt/6b24c15cbf231221f0f13239e42becfe to your computer and use it in GitHub Desktop.
Xamarin.Forms Markup Extension Example
[ContentProperty("FriendlyName")]
public class FriendlyThickness : IMarkupExtension
{
public FriendlyThickness()
{
}
public string FriendlyName { get; set; }
public object ProvideValue(IServiceProvider serviceProvider)
{
switch (FriendlyName?.ToLower())
{
case "fatleft":
return new Thickness(50, 0, 0, 0);
case "fatright":
return new Thickness(0, 0, 50, 0);
case "skinnytop":
return new Thickness(0, 10, 0, 0);
case "skinnybottom":
return new Thickness(0, 0, 0, 10);
default:
return new Thickness();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment