10. 素のBindableProperty
var Template = new DataTemplate(typeof(AlphaCircleImageCell));
Template.SetBinding(AlphaCircleImageCell.ImageSourceProperty, "AvatarUrl");
Template.SetBinding(AlphaCircleImageCell.TextProperty, "Login");
var List = new ListView
{
ItemTemplate = Template,
};
14. 簡潔なBindableProperty
public class AlphaCircleImageCell : ViewCell
{
public static readonly BindableProperty ImageSourceProperty =
typeof(AlphaCircleImageCell).GetRuntimeProperty("ImageSource").CreateBindableProperty();
public static readonly BindableProperty TextProperty =
typeof(AlphaCircleImageCell).GetRuntimeProperty("Text").CreateBindableProperty();
...
}
15. 簡潔なBindableProperty
var List = new ListView
{
ItemTemplate = new DataTemplateEx(typeof(AlphaCircleImageCell))
.SetBinding("ImageSource", "AvatarUrl")
.SetBinding("Text", "Login"),
};
16. 簡潔なBindableProperty
var List = new ListView
{
ItemTemplate = new DataTemplateEx(typeof(AlphaCircleImageCell))
.SetBindingList("ImageSource", "Text"),
};
32. 匿名クラス
static public class ValueEx
{
public static T GetValue<T>(this object o, string name)
{
return (T)o.GetType().GetRuntimeProperty(name).GetValue(o);
}
}