-
Notifications
You must be signed in to change notification settings - Fork 177
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
extra DataTemplate instantiations on iOS #158
Comments
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.
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 (oxyplot/oxyplot-xamarin#60).
The text was updated successfully, but these errors were encountered: