Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

Xamarin Forms Lab GridView

$
0
0

Hello, I'm trying to use GridView from Forms Lab. Problem is that I'm not getting anything shown on screen. One thing to note - when i set Content = gridView or Content = mainLayout I'm getting null pointer reference exception, but i cannot find out which element is null.
Here's code in view :

var itemTemplate = new DataTemplate(typeof (MedicineBoxItemCell));
              var gridView = new GridView();
               gridView.ItemsSource = medicineBoxViewModel.MedicineBoxViewModelItems;

            gridView.ItemTemplate = itemTemplate;
//            gridView.ItemWidth = gridView.ItemHeight = display.Width / 2;

            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;
                    }
                }`     

Viewing all articles
Browse latest Browse all 58056

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>