Xamarin.Forms Binding Specified cast is not valid
I had this problem too, the issue was with the xaml
. I had a <StackLayout>
inside of my <DataTemplate>
, you can remove your <Grid>
and that should solve the problem.
Did you know that you could replace the <Grid>
with an <ImageCell>
:
<ListView.ItemTemplate>
<DataTemplate>
<ImageCell
Text="{Binding GiftName}"
Detail="{Binding GiftDescription}"
ImageSource="{Binding GiftImage}">
</ImageCell>
</DataTemplate>
</ListView.ItemTemplate>
Remove the <ViewCell>
from the DataTemplate. This should resolve the error. <Grid>
will work in <CollectionView>
<ListView.ItemTemplate>
<DataTemplate>
<Grid>
:
:
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
You can place inside with .
Something like this
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout>
</StackLayout>
</ViewCell>
</DataTemplate>