Created
July 10, 2017 11:31
-
-
Save codemillmatt/6b24c15cbf231221f0f13239e42becfe to your computer and use it in GitHub Desktop.
Xamarin.Forms Markup Extension Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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