0
我想从Forms Lab中使用GridView。问题是我没有在屏幕上显示任何内容。有一点要注意 - 当我设置Content = gridView或Content = mainLayout时,我得到空指针引用异常,但我找不到哪个元素为null。这里的代码在视图中:Xamarin Forms Labs GridView没有显示
var itemTemplate = new DataTemplate(typeof (MedicineBoxItemCell));
var gridView = new GridView();
gridView.ItemsSource = medicineBoxViewModel.MedicineBoxViewModelItems;
gridView.ItemTemplate = itemTemplate;
StackLayout mainLayout = new StackLayout();
mainLayout.Children.Add(gridView);
var scrollView = new ScrollView()
{
Content = mainLayout,
BackgroundColor = Color.Yellow
};
Content = scrollView;
}
public class MedicineBoxItemCell : ViewCell
{
public MedicineBoxItemCell()
{
var name = new Entry()
{
HorizontalOptions = LayoutOptions.FillAndExpand
};
name.SetBinding(Entry.TextProperty, "MedicineBoxItem.Medicine.Name");
View = name;
}
}`
我在Android上测试。 即使当我尝试网格单元格是TextCell类型它不起作用。 基本问题是,我无法将GridView添加到Page的内容。 内容= gridView抛出零点异常 – 2014-08-29 08:27:42
它没有在android中实现..但使用模板有问题.. 我们需要帮助在那里随时提供您的输入: https://github.com/的XForms/Xamarin-表单实验室 – 2014-08-29 14:45:09