System.NullReferenceException: Object reference not set to an instance of an object.
See original GitHub issueGetting 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.
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (6 by maintainers)
Top Results From Across the Web
Object Reference Not Set to an Instance of an Object
This exception is thrown when you try to access a member—for instance, a method or a property—on a variable that currently holds a...
Read more >c# - What is a NullReferenceException, and how do I fix it?
The message "Object not set to an instance of Object" means you are trying to use an object which has not been initialized....
Read more >How can I fix the error: System.NullReferenceException
When you have a statement like A.B.C = E.F; , and you receive an NullReferenceException 'Object reference not set to an instance of...
Read more >Object reference not set to an instance of an object” error?
The “Object reference not set to an instance of an object” is a very famous error in C# that appears when you get...
Read more >Get to the Bottom of C# Object Reference Not Set to an ...
So, this error description says that an object that is being called to get or set its value has no reference. This means...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
@Nixon-Joseph Where did you go?(