roubachof / Sharpnado.CollectionView

A performant list view supporting: grid, horizontal and vertical layout, drag and drop, and reveal animations.
The Unlicense
244 stars 30 forks source link

NullReferenceException When trying to bind list to ItemsSource #48

Closed zer0Ambit1on closed 2 years ago

zer0Ambit1on commented 2 years ago

Hello, Just wanna try your awesome nuget, but if i bind ObservableCollection to ItemsSource it generate NRE.

But if List is "Null" app started without exception. Can you help?

roubachof commented 2 years ago

How I can help without example ? I can't 😎

zer0Ambit1on commented 2 years ago

Sorry for long reply public partial class MainPage : ContentPage { public ObservableCollection ImagesArray { get; set; } = new ObservableCollection(); public MainPage() { InitializeComponent(); BindingContext = this; ImagesArray.Add(new MyList() { ImageName = "Image1.png" }); ImagesArray.Add(new MyList() { ImageName = "Image2.png" }); ImagesArray.Add(new MyList() { ImageName = Image3.png" }); ImagesArray.Add(new MyList() { ImageName = "Image4.png" }); ImagesArray.Add(new MyList() { ImageName = "Image5.png" }); ImagesArray.Add(new MyList() { ImageName = "Image6.png" }); ImagesArray.Add(new MyList() { ImageName = "Image7.png" }); ImagesArray.Add(new MyList() { ImageName = "Image8.png" }); ImagesArray.Add(new MyList() { ImageName = "Image9.png" }); ImagesArray.Add(new MyList() { ImageName = "Image10.png" }); } My XAML:

StackLayout> /StackLayout>
roubachof commented 2 years ago

You need to set the ItemHeight property

zer0Ambit1on commented 2 years ago

i have set this value, but all the same it generate exception .

SarthakGz commented 2 years ago

I think Item height property should not be mandatory for vertical layout it should calculate according to content itself.

roubachof commented 2 years ago

nope, this is the whole philosophy of the Sharpnado CollectionView, don't measure it self, specify static height by data template to allow cell reuse. If you measure all, it breaks cell reuse philosophy since you have to make a layout pass for each cell displayed...

roubachof commented 2 years ago

sorry can't do anything with so little information