This is a migrated thread and some comments may be shown as answers.

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

7 Answers 180 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Dan
Top achievements
Rank 1
Dan asked on 02 Dec 2017, 11:56 PM

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?

 

7 Answers, 1 is accepted

Sort by
0
Accepted
Yana
Telerik team
answered on 06 Dec 2017, 04:15 PM
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
0
Dan
Top achievements
Rank 1
answered on 07 Dec 2017, 01:09 PM

thank you :)

 

0
Dan
Top achievements
Rank 1
answered on 07 Dec 2017, 01:17 PM

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...

0
Lance | Manager Technical Support
Telerik team
answered on 07 Dec 2017, 04:27 PM
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
0
Dan
Top achievements
Rank 1
answered on 08 Dec 2017, 12:48 AM

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.

 

0
Dan
Top achievements
Rank 1
answered on 08 Dec 2017, 12:26 PM

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.

0
Lance | Manager Technical Support
Telerik team
answered on 07 Mar 2019, 05:51 PM
Hello all,

I'm just updating this thread with a new version of the demo.

The original demo uses the deprecated PCL project type as well as deprecated project structures for the target platform projects.

The new attached project uses .NETStandard 2.0, Xamarin.Forms 3.4 and the NETStandard-compliant SQLite packages. Visit the official Microsoft Documentation for a full tutorial on how to set up SQLite in a Xamarin.Forms application.

This solution uses UI for Xamarin v 2019.1.220 via Telerik NuGet server and the RadListView is used to display database items. The project has all three target platforms.

Here's a screenshot of the Android project running on a Android 8.1 emulator.




Regards,
Lance | Technical Support Engineer, Principal
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
Tags
ListView
Asked by
Dan
Top achievements
Rank 1
Answers by
Yana
Telerik team
Dan
Top achievements
Rank 1
Lance | Manager Technical Support
Telerik team
Share this question
or