Still struggling with the whole viewmodel and binding to a listview row

7 posts, 1 answers
  1. Dan
    Dan avatar
    18 posts
    Member since:
    Apr 2013

    Posted 02 Dec 2017 Link to this post

    I'm really struggling with the whole viewmodel and binding to a listview row.

    I want to pull data from my sqlite table, and use one of the fields for my text label bound in my listview.

    Can someone give me a working example of a binding in a listview pulling just one column from a sqlite table and putting each field on a single row label in the listview?

    <listView:ListViewTemplateCell>

    <StackLayout BackgroundColor="Bisque" Padding="5" Spacing="5">

    <Label Text="{Binding Category}" TextColor="Black" />

    </StackLayout>

    </listView:ListViewTemplateCell>

    How to make a query put each item into that label for rows in my listview?

     

  2. Answer
    Yana
    Admin
    Yana avatar
    4720 posts

    Posted 06 Dec 2017 Link to this post

    Hi Dan,

    I have attached a simple example to demonstrate how to populate RadListView using data from SQlite database.  The example is based on the Todo sample explained in details in Local Databases topic inside Xamarin.Forms documentation.   Additionally, I created a ViewModel class with a property of type ObservableCollection that holds the Categories retrieved from the database.  The ViewModel is then set as a BindingContext so that the bindings inside ListView template would work.

    Please check the attached file and let me know if you have any questions or concerns.

    Regards,
    Yana
    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
  3. Dan
    Dan avatar
    18 posts
    Member since:
    Apr 2013

    Posted 07 Dec 2017 in reply to Yana Link to this post

    thank you :)

     

  4. Dan
    Dan avatar
    18 posts
    Member since:
    Apr 2013

    Posted 07 Dec 2017 in reply to Yana Link to this post

    I can't even uninstall the "trial" version of telerik for xamarin so I can install the full version.  It only gives me a "restore" option and nothing else.  When I go to manage nuget and try to uninstall it still gives me no options.

    So, I can't build this example...

  5. Lance | Tech Support Engineer, Sr.
    Admin
    Lance | Tech Support Engineer, Sr. avatar
    821 posts

    Posted 07 Dec 2017 Link to this post

    Hello Dan,

    The demo uses the Telerik NuGet server for UI for Xamarin. The reason you're having trouble is because you likely have not added the Telerik NuGet server to your NuGet Package Sources. Telerik.UI.For.Xamarin.Trial package is not published to nuget.org, it's published to nuget.telerik.com/nuget.

    Fix 

    To quickly fix this, go to this documentation and follow the steps in the Visual Studio section.  In short, you're adding the Telerik package source to the Package Sources so that the Package Manager will be able to find (and install) a NuGet package  named "Telerik.UI.For.Xamarin.Trial".


    Restore and Build 


    Once the package source is there, open the the Package Manager you will be able to find the "Telerik.UI.for.Xamarin.Trial" package,  Here's a screenshot of the Package Manager, notice that I call out the Package source dropdown, This is important because if you have "nuget.org" selected, the UI for Xamairn Package won't listed).



    Wrapping Up

    Using our NuGet server has the major benefitr that it's much easier to update your project to newer versions of UI for Xamarin when updates are released. It also means that you do not need to install UI for Xamarin to every machine that you use for development.

    Let me know if you have any trouble. Worst case scenario, say for example you're behind a firewall that doesn't allow the connection, I can update Yana's demo to use local DLLs instead.

    Regards,
    Lance | Tech Support Engineer, Sr.
    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
  6. Dan
    Dan avatar
    18 posts
    Member since:
    Apr 2013

    Posted 07 Dec 2017 in reply to Lance | Tech Support Engineer, Sr. Link to this post

    Sorry, I didn't give you enough information.  What I was referring to is that I am working in the NuGet package manager in my Telerik NuGet source and I am trying the following:

    I can't uninstall the "trial" version of telerik for xamarin. It only gives me a "restore" option and
    nothing else.

    When I go to manage nuget and try to uninstall it still gives me no options other than "restore".

    I can't install my licensed version because I can't remove the trial version.

     

  7. Dan
    Dan avatar
    18 posts
    Member since:
    Apr 2013

    Posted 08 Dec 2017 Link to this post

    I managed to get it removed by editing the packages.config files and removing the trial version, and then restarting VS, then install the telerik ui for xamarin.

    Thank you again.

Back to Top