【发布时间】:2015-08-19 21:23:34
【问题描述】:
我有一个本机 (Xamarin.Forms) 列表视图。我的数据上下文有 3 个属性,例如:
public class MyDataContext :
{
public string Name {get;set;}
public string ImageName {get;set;}
public bool isAvailable {get;set;}
}
其中 Name 是 textLabel 的属性,ImageName 是 ImageControl 的图像源并且 isAvailable 某种单元格条件(true - 单元格处于活动状态,否则 Cell 具有另一个不透明度/背景并且不是 可点击,也会出现一个图像(在右上角),将显示图像“locked”!)。
我当前的列表视图:
public class MyListView: ListView
{
public MyListView()
{
ItemTemplate = new DataTemplate(()=>
{
BackgroundColor = Color.FromHex("#f2f0e9");
var _Label = new Label() { FontSize = 13, TextColor = Color.FromHex("#979797")};
_Label.SetBinding(Label.TextProperty,"Name");
RowHeight = 69;
var _Img = new Image(){ WidthRequest = 35, HeightRequest = 42};
_Img.SetBinding(Image.SourceProperty,"ImageName");
return new ViewCell
{
View = new StackLayout
{
Orientation = StackOrientation.Horizontal,
Padding = 10,
Children =
{
_Img,
new StackLayout
{
Padding = 10,
VerticalOptions = LayoutOptions.Center,
Spacing = 0,
Children =
{
_Label,
}
}
}
}
};
});
}
}
}
出于某种原因,我需要自定义(iOs/Android 两个平台):
我怎样才能做到这一点?
任何帮助将不胜感激,谢谢!
PS对不起我的英语。技能!
【问题讨论】:
标签: c# xamarin.ios xamarin.android xamarin.forms