Xamarin Form Error Value cannot be null. Parameter name: type

George M Ceaser Jr picture George M Ceaser Jr · Nov 27, 2016 · Viewed 7.9k times · Source

All day I was receiving this very clear (not the sarcasm) error message "Value cannot be null. Parameter name: type" I was hitting my head against the wall slowly decomposing my code until I could figure out the exact cause of the problem. After much tedious deconstruction I discovered that I had an error in my GestureRecognizers section. The problem was that I accidentally typed Command to try to pass a parameter instead of CommandParameter.

My original code generating the error looked like this.

<Label.GestureRecognizers>
    <TapGestureRecognizer Tapped="Value_Tapped" Command="language" />
</Label.GestureRecognizers>

The corrected code is this:

<Label.GestureRecognizers>
    <TapGestureRecognizer Tapped="Value_Tapped" CommandParameter="language" />
</Label.GestureRecognizers>

I hope this helps someone else in the future.

Answer

George M Ceaser Jr picture George M Ceaser Jr · Nov 30, 2016

It appears if you try to set the Command property to something Xamarin Forms does not know you will get this error. If you get the error I suggest double checking all the non-intelisense correct parameters in your code.