Closed fschwiet closed 7 years ago
There's no way to avoid this. In iOS, SizeChanged is called multiple times. Sometimes one time, sometimes two, and that's something i cannot control.
Also, internally UIPageViewController creates the next page for smooth swiping and that's what you maybe seeing.
Found a way to prevent multiple calls. Next release.
Thank you Alex.
Also, internally UIPageViewController creates the next page for smooth swiping and that's what you maybe seeing.
This sounds ok, as long as the instantiations for each DataTemplate don't overlap.
I did hit the crash in my project on Android, indicating one of the DataTemplates is being created twice. I haven't been able to repro it with the test project though. So I may still need to use the oxyplot workaround.
It makes me wonder if it'd be better (I don't think its possible now) to just pass in an array of Views instead of DataTemplates (in this case the number of views is quite small). I might give that a try, it seems like I could just make a change to where ever the current code checks for a DataTemplate.
I created a branch with tracing to highlight the issue: https://github.com/fschwiet/CarouselView/tree/view-double-constructed
Repro steps:
I can understand if this doesn't seem like a big deal, really its just a slight performance cost in most scenarios. In my scenario though I am using OxyPlot in the first DataTemplate and OxyPlot won't let you bind its PlotModel to more than one view, so I get an exception. There is a work-around to make it work in OxyPlot, but its complicated and I'd rather not. OxyPlot has had this restriction for a long time so I doubt they're going to change their behavior now (https://github.com/oxyplot/oxyplot-xamarin/issues/60).