Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

System.NullReferenceException: Object reference not set to an instance of an object. #9

Closed
Nixon-Joseph opened this issue Mar 16, 2018 · 9 comments
Labels
resolved Waiting for validation wontfix This will not be worked on

Comments

@Nixon-Joseph
Copy link

Getting a null reference exception when trying to initialize the carousel view. I don't have a lot of info, because I can't track down the source of the exception, and no amount of try-catches have been able to narrow it down.

I'm trying to use your carousel, because the only other decent option has stopped support, and is giving me too much grief.

My code for initializing the carousel is:

var carousel = new PanCardView.CarouselView()
            {
                ItemTemplate = new DataTemplate(() =>
                {
                    var img = new CachedImage();
                    img.SetBinding(CachedImage.SourceProperty, "ImageUrl");
                    //img.Clicked += Image_Clicked;
                    return new ViewCell() { View = img };
                })
            };
            carousel.SetBinding(PanCardView.CarouselView.ItemsProperty, nameof(CarouselImages));
            carousel.SetBinding(PanCardView.CarouselView.CurrentIndexProperty, nameof(CarouselPosition));

            CarouselViewContainer.Children.Add(carousel);

From what I can tell, the exception gets thrown sometime after the code runs the return new ViewCell() { View = img }; line.

@AndreiMisiukevich
Copy link
Owner

Hi
Thanks for feedback
Could you please change ViewCell yo ContentView and try it ?

I will investigate this problem little bit later

@Nixon-Joseph
Copy link
Author

ContentView worked! thanks.

@Nixon-Joseph
Copy link
Author

Let me know if you want me to open a new issue or not. But I've found that (in android) swiping between images can be finicky. Sometimes the image will stick slightly off to the side, sometimes it won't detect the swipe at all.
I haven't tested as extensively in ios, but my initial impression is it works a little better.

This plugin is great though. Excellent work.

I might ask for one addon though, could you add a click/tap event to a slide/card?

@AndreiMisiukevich
Copy link
Owner

Yes, please. Creating separate issue would be awesome.

I think, you can close this, because this plugin supports only views as card items.. viewcell doesn't match t

@AndreiMisiukevich
Copy link
Owner

Sorry.. i'm writtinf from my mobile phone...
I just want to say, that viewcell isn't view.. it extends from visualelement directly

@AndreiMisiukevich
Copy link
Owner

But as for detecting swipe, try to set InCourse property to false

@AndreiMisiukevich
Copy link
Owner

By the way, you can add tap or click by youself)
Just add tapgesture to your card item (check sample)

@AndreiMisiukevich AndreiMisiukevich added wontfix This will not be worked on resolved Waiting for validation labels Mar 17, 2018
@AndreiMisiukevich
Copy link
Owner

@Nixon-Joseph Where did you go?(

@Nixon-Joseph
Copy link
Author

Sorry, it was my weekend, and this is a work project. I ViewCell not being a view makes a lot of sense, I'll keep that in mind. I guess I was thinking of it as a ListView.

I'll try the InCourse property today and see if that helps. And I did add a tap event myself, it's not a huge thing, just thought it would be nice to have built in :)

The last carousel I used was intercepting all input, I couldn't even add a tap listener to the element containing the carousel. It just wouldn't fire. Yours seems great.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
resolved Waiting for validation wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants