You must have an ObservableCollection and set ItemSource property to the collection, otherwise your listview does not know data to visualize
System.InvalidCastException: 'Specified cast is not valid. Xamarin.Forms
Hi Everyone ! i have this project in which i need to Retrieve a list of data, when i click the Retrieve Button, the app enters in break mode and shows me an error saying
System.InvalidCastException: 'Specified cast is not valid.'
Accroding to what i've found the issue is with the ListView
block, but im not quite sure, please find it here attached
<ListView x:Name="ListEstudiantes">
<ListView.ItemTemplate>
<DataTemplate>
<TextCell Text="{Binding Name}">
</TextCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
If you need a Demo please let me know!
2 answers
Sort by: Most helpful
-
-
Leon Lu (Shanghai Wicresoft Co,.Ltd.) 76,386 Reputation points Microsoft Vendor
2020-12-28T05:44:51.657+00:00 Hello,
Welcome to our Microsoft Q&A platform!
the things is that i need to Search an Student by an specific condition and display the information in the Text Fields, but when i do it the exception pops up, but the List >View is working now properly
Do you meen when you click the
btnRetrive
, when you will get theSpecified cast is not valid. Xamarin.Forms
?If so, you should change
txtCedula
totxtCedula.Text
like following code. BecausetxtCedula
is entry, if you want to get the text from the entry, you could addText
property.var Estudiante = await FireBaseHelper.GetEstudiante(Convert.ToInt32(txtCedula.Text)).ConfigureAwait(true);
Note: If you solved this issue, please delete the demo link in the comment, it contains your privacy information, If you have any other issues about firebase, you do not share the baseUrl. Just emty it, then share test record's data-structor in firebase DB.
Best Regards,
Leon Lu
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.