When building mobile app UI that requires controls and transitions that are not available from the platform “out-of-the box”, we either create our own or use a third-party library to accomplish the design. I had a similar need recently for gauges and charts in one of my client’s Xamarin.Forms application. Telerik UI for Xamarin makes it a breeze to get your UI looking good, fast.

Having built IntelliAbb.Xamarin.Controls – my own Open Source Software (OSS) controls library for Xamarin.Forms, I first thought about creating my own. But under the common sense of not “reinventing the wheel”, I looked around for other OSS and third-party libraries that could accelerate my mobile development. While there are several great offerings out there for Xamarin controls by Telerik (Progress), Syncfusion, GrailKit, Aurora, etc. I decided to start with Telerik UI for Xamarin. In this post I will share my experience building a list view with grouping, expand/collapse view, followed by charts, gauges, etc. along with some lessons learned.

Toolkit

Telerik has an extensive list of components for Xamarin.Forms, Xamarin.iOS, and Xamarin.Android. One can easily build an entire app with Telerik UI for Xamarin given their excellent documentation.

Documentation

Telerik team did an excellent job on their documentation. The documentation covers each component in a structured manner with examples in XAML, code-behind, and also DataBinding using MVVM pattern.

Getting Started

If you are not sure Telerik has what you need, you can start with a free trial. Go start your trial, go to www.telerik.com and click on Get Free Trial button. Select Telerik UI for Xamarin under Mobile section, then fill out some info and download the SDKs. Follow the setup steps show in https://docs.telerik.com/devtools/xamarin/getting-started to get up and running on Windows or Mac.

Note: I highly recommend you install the Telerik Visual Studio extension for Windows or Mac that comes with Telerik Project templates. It makes it a lot simpler with all the available namespaces already configured in your XAML file.

ListView, Grouping, Expand/Collapse

In this post, we will build a ListView and groups its content. We will also style the header and get expanding/collapsing. And all this following MVVM pattern with DataBinding 👍

👀 Beware

ListView in Telerik UI for Xamarin looks similar to ListView from Xamarin.Forms at first. But as soon as you start to customize the ListView or cells in the ListView, you will realize that it is not. Compared to Xamarin.Forms ListView, ListView in Telerik UI for Xamarin offers better performance and virtualization, load on demand, data operations, layout modes, and the additional features like swipe gestures, sticky headers, and much more (not covered in this post). So, make sure you keep the documentation handy to explore the ListView APIs.

Lets start setting up the ListView,

Step 1 – Data

Before we jump into building the ListView, let’s get the data ready. Nothing special here, just a Model with a ViewModel that provides DataBinding, so really quickly here’s the setup for our ListView,

Model

ViewModel

Now, let’s build the view.

Step 2 – Define Namespaces

Note: All the namespaces are automatically added to your XAML file if you are using Telerik Visual Studio extensions mentioned above.

Step 3 – RadListView

RadListView requires some configuration before it looks how we expect it to. This is where things are a little different than Xamarin.Forms.ListView . Let’s start

Step 4 – LayoutDefinition

RadListView does not have HasUnevenRows or RowHeight property, which means you cannot set cell/row height at RadListView level. Instead, RadListView has a LayoutDefinition property that configures the layout of the RadListView . You can set the type of layout (Linear or Grid) as well. Pretty cool.

For our example, we are using Linear layout and to set the height of our cell/row, we set ItemLength of ListViewLinearLayout which is in Telerik.XamarinForms.DataControls.ListView namespace.

<telerikDataControls:RadListView.LayoutDefinition> <telerikListView:ListViewLinearLayout ItemLength="200" /> </telerikDataControls:RadListView.LayoutDefinition>

Step 5 – Grouping

This is where RadListView shines. Using out-of-the-box Xamarin.Forms.ListView requires some sort of a collection of a collection in order to achieve grouping, in RadListView , we simply provide the grouping property name to the RadListView by setting its GroupDescriptors property (which is in namespace Telerik.XamarinForms.DataControls.ListView ). Simply,

Group Header

Once we have set GroupDescriptors , we create the header view. Note how in the line highlighted below, we bind the Text property to the property named in the GroupDescriptors .

Step 6 – List Items Template

RadListView has two types of Cells, ListViewTextCell and ListViewTemplateCell. As the name suggest, for simple text list items we can use former, but for more complex views, we use the later. In our example, we use ListViewTemplateCell.

Full view is here.

Final result (will talk about the gauges next).

With a little bit of learning and navigating the docs, I find that Telerik UI for Xamarin makes it a breeze to get your UI looking good, fast.

Charts 📊 And Gauges 🌡️

Charts and Gauges require separate posts. In coming weeks, I will have a post on Charts and how to customize the chart to look more modern. Similarly, how to customize a gauge quickly to make it fit in your design with ease. Stay tuned.

Resources

Sample code: https://github.com/hnabbasi/TelerikListView