ListView:ListViewGridLayout causing "Specified cast is not valid"

4 posts, 0 answers
  1. Brian
    Brian avatar
    12 posts
    Member since:
    Apr 2018

    Posted 22 Jan 2019 Link to this post

    Hi, I'm sure this is something I'm just missing but I need another pair of eyes...  I have a Content Page that I put the below listview in it and I wanted the list to have a span count of 2, like your example online.   I was have trouble with the layout and I removed the LayoutDefinition and once it started working properly (single list view) I add the Definition back in (copy/paste) and compiled and got the error.

    If I remove the LayoutDefinition tag it works....

    My includes:

    xmlns:tDataCtrl="clr-namespace:Telerik.XamarinForms.DataControls;assembly=Telerik.XamarinForms.DataControls"
    xmlns:tListView="clr-namespace:Telerik.XamarinForms.DataControls.ListView;assembly=Telerik.XamarinForms.DataControls"
                

     

     

    <tDataCtrl:RadListView x:Name="memberList" ItemsSource="{Binding TeamMembers}"  Margin="20,0,0,0"   BackgroundColor="White"   VerticalOptions="FillAndExpand" IsVisible="{Binding MembersVisible}">
                
                                  <tDataCtrl:RadListView.ItemTemplate>
                                    <DataTemplate>
                                      <tListView:ListViewTemplateCell>
                                        <tListView:ListViewTemplateCell.View>
                                             <Grid BackgroundColor="White">
                                                <Grid.RowDefinitions>
                                                  <RowDefinition Height="220"/>
                                                  <RowDefinition Height="18"/>
                                                  <RowDefinition Height="18"/>
                                                </Grid.RowDefinitions>
                                                <Grid.ColumnDefinitions>
                                                  <ColumnDefinition Width="Auto"/>
                                                </Grid.ColumnDefinitions>
                                                <ff:CachedImage Source="{Binding Image}"  HeightRequest="220"    Aspect="AspectFit"    Grid.Row="0"   
                                                          HorizontalOptions="CenterAndExpand"   VerticalOptions="CenterAndExpand"  Margin="0,0,10,0"/>
                                                <Label Text="{Binding FullName}"   FontSize="{Binding RoleToPresent}"   LineBreakMode="WordWrap"    TextColor="Black"  Margin="8,0,8,0" Grid.Row="1" HorizontalOptions="Start"/>
                                                <Label Text="{Binding RoleToPresent}" FontSize="{Binding RoleToPresent}" LineBreakMode="WordWrap"   TextColor="Black" Margin="8,0,8,0"  Grid.Row="2" HorizontalOptions="Start"/>
                                             </Grid>       
                                            </tListView:ListViewTemplateCell.View>
                                          </tListView:ListViewTemplateCell>
                                        </DataTemplate>
                                      </tDataCtrl:RadListView.ItemTemplate>
                                       <tDataCtrl:RadListView.LayoutDefinition >
                                 
                                            <tListView:ListViewGridLayout Orientation="Vertical"  ItemLength="280"  SpanCount="2"    VerticalItemSpacing="30"  HorizontalItemSpacing="30"/>
                                       </tDataCtrl:RadListView.LayoutDefinition>
                            </tDataCtrl:RadListView> 

     

     

    Thank you,

    Brian

  2. Brian
    Brian avatar
    12 posts
    Member since:
    Apr 2018

    Posted 22 Jan 2019 Link to this post

    Ok, I fixed by putting the LayoutDefinition about the ItemTemplate, which worries me. What do I have declared in the ItemTemplate thattells the compiler to expect a different class in the LayoutDefinition??  uhg! 

    I still need another set of eyes to review and tell me where I'm going wrong here please.

    Thanks,

    Brian

  3. Didi
    Admin
    Didi avatar
    356 posts

    Posted 24 Jan 2019 Link to this post

    Hi Brian,

    Thank you for the provided code.

    I have created a sample based on the attached code but I the RadListView GridLayout definition works as expected. Please take a look at the attached project. Could you please give us more information about:

    - which versions of Telerik UI for Xamarin and Xamarin.Forms are used in the project
    - on which platform the issue can be reproduced.

    Also could you please verify that the issue can be reproduced in the attached project. If not, may I ask you to modify it according your setup and send it back to me? In this way I could research it further. Please note that you should open a support ticket and attach the project there because in the forum only image attachments are allowed.

    Looking forward to your reply.

    Regards,
    Didi
    Progress Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  4. Brian
    Brian avatar
    12 posts
    Member since:
    Apr 2018

    Posted 24 Jan 2019 Link to this post

    HI Didi, I went back to the view where this occurred and I am compiling without error even if the LayoutDefinition is below the template so I'm not sure why it error earlier.   I also loaded your project and it too is compiling.   It must have been something temporary.  I'd say this is not an issue.

    Thank you!

    B

Back to Top