Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

Type Exception when adding seperate groups to a listview in forms and deploying to IOS with live

$
0
0

So i am trying to add multiple groups of items to a listview in xamarin forms. It works perfectly fine with just simple objects as such:

    todoListView.ItemsSource = new List<TodoItem> 
                {
                        new TodoItem{ TimeLeft="13:30", Location="The Room", Title="IM AN URGENT TITLE!", ImageURL="Unread.png", Unread=true, TodoText="This is some random text to illustrate a useless point." },
                        new TodoItem{ Title="IM A TITLE!", ImageURL="Unread.png", Unread=true, TodoText="This is some random text to illustrate a useless point." }
                };

But when i add a group like this:

        todoListView.ItemsSource = new List<TodoListGroups>
        {
            new TodoListGroups("Test")
            {
                new TodoItem{ Title="IM A TITLE!", ImageURL="Unread.png", Unread=true, TodoText="This is some random text." }
            }
        };

I get the following error: Object of type 'Ninterpret.interpretedObject' doesn't match type 'System.Collections.Generic.List`1[Ninterpret.interpretedObject]' (TargetException)

My model looks like this:
    using System;
    using System.Collections.Generic;
    using System.Text;

    namespace xyz
    {
        public class TodoListGroups : List<TodoItem>
        {
            public string Title { get; set; }

            public TodoListGroups(string title)
            {
                Title = title;
            }
        }
    }

The xaml for reference is:

    <ContentPage Icon="list.png" Title="Todos">
                <StackLayout Orientation="Vertical">
                    <ListView SeparatorColor="OrangeRed" x:Name="todoListView" HasUnevenRows="True" IsGroupingEnabled="True" GroupDisplayBinding="{Binding Title}">
                        <ListView.ItemTemplate>
                            <DataTemplate>
                                <ViewCell>
                                    <StackLayout Orientation="Horizontal" Padding="5">
                                        <Image Source="{Binding ImageURL}"></Image>
                                        <StackLayout HorizontalOptions="StartAndExpand">
                                            <Label Text="{Binding Title}"></Label>
                                            <Label Text="{Binding TodoText}" TextColor="Gray"></Label>
                                        </StackLayout>
                                        <Button Text="Done"></Button>
                                    </StackLayout>
                                </ViewCell>
                            </DataTemplate>
                        </ListView.ItemTemplate>
                    </ListView>
                </StackLayout>
            </ContentPage>

Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>