Last active
September 29, 2020 10:49
-
-
Save mr5z/28754745d48a128472e21b5f9635bcc3 to your computer and use it in GitHub Desktop.
Shortened or lessen the input parameter to Xamarin.Forms.BindableProperty.Create()
This file contains hidden or 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
public static BindableProperty CreateProperty<T>(T defaultValue = default, BindingMode mode = BindingMode.TwoWay, [CallerMemberName] string propertyName = null) | |
{ | |
propertyName = RemoveLastOccurrence(propertyName, "Property"); | |
return BindableProperty.Create(propertyName, typeof(T), typeof(BindableObject), defaultValue, mode); | |
} | |
private static string RemoveLastOccurrence(string source, string toFind) | |
{ | |
var index = source.LastIndexOf(toFind); | |
return index == -1 ? source : source.Substring(0, index); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment