Moan Start
I guess I should have learnt my lesson and not upgraded all my projects to the latest XF assembly (2.5.0.121934). I like Xamarin but I really dislike the appalling testing (or lack of) on simple things that really should have been tested - I spend so much of my time working around such an unstable environment and writing things multiple ways because of the numerous bugs that are inherent within the API , We are at 2.5 soon to be XF 3.0 and my patience is really running thin to say the least - Xamarin/Microsoft , it would be great if at each new release you could try a little harder NOT TO BREAK what was working in prior versions , is that really too much to ask ??
Moan End
Exception
System.InvalidCastException: Specified cast is not valid.
at (wrapper castclass) System.Object:__castclass_with_cache (object,intptr,intptr)
at Xamarin.Forms.Platform.iOS.VisualElementRenderer`1[TElement].Xamarin.Forms.Platform.iOS.IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00000] in :0
at Xamarin.Forms.Platform.iOS.RendererPool.UpdateRenderers (Xamarin.Forms.Element newElement) [0x0008c] in \agent_work\1\s\Xamarin.Forms.Platform.iOS\RendererPool.cs:157
at Xamarin.Forms.Platform.iOS.RendererPool.UpdateNewElement (Xamarin.Forms.VisualElement newElement) [0x00080] in \agent_work\1\s\Xamarin.Forms.Platform.iOS\RendererPool.cs:78
at Xamarin.Forms.Platform.iOS.VisualElementPackager.SetElement (Xamarin.Forms.VisualElement oldElement, Xamarin.Forms.VisualElement newElement) [0x00050] in \agent_work\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:1
How to reproduce
So - this bug is easily reproducible - I've tested on a live iPhone X and also simulators running 11.2. Quite simply, just create a navigation page that navigates to a content page. On this content page - just have a simple TableView with 3-4 sections. In Each section - have about 5-8 ViewCells with a grid that defines two star based columns.
Then ensure that the Grids that you have for each ViewCell mixes up a combination of Labels and BoxViews, and Labels and Switches, i.e
**
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Label
Grid.Column="0"
HorizontalOptions="Start"
Text="Message 1" />
<BoxView
Grid.Column="1"
BackgroundColor="Red"
HeightRequest="30"
Scale="1"
WidthRequest="30" />
</Grid>
**
Run App
So once you have deployed the APP onto a device/simulator - to get the app to crash - you need to rapidly hold your finger on your screen and swipe up and down so that the TableView contents will move up and down - doing this for a few seconds will give you the crash.
For your convenience, I have attached the complete View to this post - I use Prism so if you dont use that, just remove the references to Prism in the ContentPage header and you will be all set .
Our app has loads of ViewCells and they are all broken beyond repair - running under XF 2.3.4.270 , the issue doesnt arise - this issue coupled with the outstanding GestureRecognizer issue in Android whereby touch events just dont work (Any UI elements where GR's are attached, you need to touch the controls 5-8 times before the event is raised!) means that we cannot move past XF 2.3.4.270 as there currently isnt a XF version post this that fixes these and all the other issues....
Sample UI