locked
How to add the items in the sublist in listview from sqlite database RRS feed

  • Question

  • How to add the items in the sublist in listview from sqlite database.

    I know how to add it directly

    class Menu
        {
            public ObservableCollection<TopMenu> TopMenuItems { get; set; }
            public Menu()
            {
                TopMenuItems = new ObservableCollection<TopMenu>();
            }
        }
     
        class TopMenu
        {
            public string GroupName { get; set; }
            public ObservableCollection<SubMenu> SubMenuItems { get; set; }
            public TopMenu()
            {
                SubMenuItems = new ObservableCollection<SubMenu>();
            }
        }
     
        class SubMenu
        {
            public string ItemName { get; set; }
        }


                Menu menu = new Menu();
                menu.TopMenuItems.Add(new TopMenu() { GroupName = "Basic Reports - Mobile" });
                menu.TopMenuItems[0].SubMenuItems.Add(new SubMenu() { ItemName = "Sales Reports - mobile" });
                menu.TopMenuItems.Add(new TopMenu() { GroupName = "Enhanced Reports - Mobile" });
                menu.TopMenuItems[1].SubMenuItems.Add(new SubMenu() { ItemName = "Subcategory Month - mobile" });
                menu.TopMenuItems[1].SubMenuItems.Add(new SubMenu() { ItemName = "Top Categories - mobile" });
                this.DataContext = menu;

    <StackPanel Orientation="Vertical">
                <ListView Name="groupListView" ItemsSource="{Binding TopMenuItems}" CanDragItems="True"CanReorderItems="True" AllowDrop="True" IsSwipeEnabled="True" SelectionMode="None">
                    <ListView.ItemTemplate>
                        <DataTemplate>
                            <StackPanel>
                                <Border x:Name="bordermenu">
                                    <TextBlock Foreground="Red" Text="{Binding GroupName}"/>
                                </Border>
                                <ListView Name="itemListViewss" ItemsSource="{Binding SubMenuItems}"CanDragItems="True" CanReorderItems="True" AllowDrop="True" IsSwipeEnabled="True" SelectionMode="None">
                                    <ListView.ItemTemplate>
                                        <DataTemplate>
                                            <StackPanel Tapped="StackPanel_Tapped">
                                                <Border x:Name="bordersubmenu">
                                                    <TextBlock Foreground="Blue" Text="{Binding ItemName}"x:Name="submenu" />
                                                </Border>
                                            </StackPanel>
                                        </DataTemplate>
                                    </ListView.ItemTemplate>
                                </ListView>
                            </StackPanel>
                        </DataTemplate>
                    </ListView.ItemTemplate>
                </ListView>
                 
                <TextBlock Name="txtSubMenuTapped" FontSize="30" Tag="Sub Menu Selected - " Text="Sub menu tapped - None"/>
            </StackPanel>

    Please let me know how to add it from the sqlite database to the sub list in listview.tell me the modifications in the above code


    amair

    Wednesday, August 7, 2013 6:50 AM

Answers

All replies

  • Why you didnt use Grouped Listview with CollectionViewSource ?

    Tutorial - http://msdn.microsoft.com/en-us/library/windows/apps/hh780627.aspx

    Or you can create Sample Grid app in VS2012 see how to use it.


    • Edited by Oleg Kurzov Wednesday, August 7, 2013 12:06 PM errors in text
    Wednesday, August 7, 2013 11:47 AM
  • Hi,shaik

    You must have tables that contain the data you want to insert into listview.When you get data from

    the sqlite database, set the data to the object you define.Then,you can refer to this link to see how

    to insert and get data from Sqlite database in Windows 8 Store Apps:

    http://blogs.msdn.com/b/robertgreen/archive/2012/11/13/using-sqlite-in-windows-store-apps.aspx

     Best Wishes!

     
    • Edited by Anne Jing Thursday, August 8, 2013 7:10 AM from
    • Marked as answer by Anne Jing Thursday, August 15, 2013 8:22 AM
    Thursday, August 8, 2013 7:09 AM
  • I will be getting the below error

    Undefined namespace. The 'using' URI refers to a namespace 'ItemsControlGroupingSnippets' that could not be found.

    Unknown type 'ListGroupStyleSelector' in XML namespace 'using:SmartDivaa.Views'

    The type 'local:ListGroupStyleSelector' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built

    The name "ListGroupStyleSelector" does not exist in the namespace "using:SmartDivaa.Views"

    please let me know the problem


    amair


    • Edited by shaik amair Monday, August 12, 2013 7:02 AM text
    Monday, August 12, 2013 6:47 AM
  • Hi,shaik

    I think you do not add the assembly reference which contain  ListGroupStyleSelector object to your app.Make sure that you already add the assembly reference to your app,and which namespace contain the  ListGroupStyleSelector object.

    I want to close this topic,because it last so long and you last question may have little relationship with it.If you have any question ,you can create a new topic and I am willing to help you!

    Best Wishes!


    Wednesday, August 14, 2013 1:51 PM
  • How to add the assembly reference of listgroupstyleselector in my application

    amair

    Thursday, August 22, 2013 1:00 PM