All docs
V20.2
20.2
20.1
The page you are viewing does not exist in version 20.1. This link will take you to the root page.
19.2
The page you are viewing does not exist in version 19.2. This link will take you to the root page.
19.1
The page you are viewing does not exist in version 19.1. This link will take you to the root page.
1.1
The page you are viewing does not exist in version 1.1. This link will take you to the root page.

Add CollectionView to Xamarin.Forms Solution

  • 3 minutes to read

This topic explains how to integrate the DevExpress CollectionView component into a Xamarin.Forms cross-platform solution.

IMPORTANT

The DevExpress CollectionView for Xamarin.Forms component is available for iOS and Android platforms, and can be used in Xamarin.Forms solutions that use the .NET Standard code sharing strategy.

For the Android project, the Target Framework and Target Android version should be Android 10 (API level 29) or later.

  1. Add the DevExpress CollectionView component to your solution in one of the following ways:

    • Install the NuGet package

      Visual Studio
      1. Obtain your NuGet feed URL
      2. Register the DevExpress NuGet feed as a package source.
        Navigate to Tools | Options | NuGet Package Manager | Package Source and add the DevExpress feed to the list of package sources.

        Register NuGet Feed - Visual Studio

      3. Install the DevExpress.XamarinForms.CollectionView package from the DevExpress NuGet feed:
        1. Select Tools | NuGet Package Manager | Manage NuGet Packages for Solution... in Visual Studio's main menu, or right-click the solution in Solution Explorer and select Manage NuGet Packages for Solution....
        2. Search for DevExpress.XamarinForms.CollectionView in the DevExpress package source, select all the solution's projects and click Install.
      Visual Studio for Mac
      1. Obtain your NuGet feed URL
      2. Register the DevExpress NuGet feed as a package source.
        Navigate to Visual Studio | Preferences | NuGet | Sources and add the DevExpress feed to the list of sources.

        Register NuGet Feed - Visual Studio for Mac

      3. Install the DevExpress.XamarinForms.CollectionView package from the DevExpress NuGet feed:
        1. Select Project | Manage NuGet Packages... in the main menu, or right-click the solution in Solution Pad and select Manage NuGet Packages...
        2. In the invoked Manage NuGet Packages dialog, select DevExpress from the Source drop-down list in the top left corner, search for DevExpress.XamarinForms.CollectionView and click Add Package.
          Select all the solution's projects in the invoked Select Projects dialog and click Ok.

      – or –

    • Add libraries from the downloaded bundle

      NOTE

      Add the Xamarin.Kotlin.StdLib NuGet package to the Android project of your Xamarin.Forms solution.

      1. Download the Mobile UI Controls for Xamarin.Forms bundle from the Client Center.
      2. Add the following assembly references to your Xamarin.Forms solution's projects:

        Project

        Assembly

        <YourAppName>

        (A .NET Standard project that contains the shared code)

        DevExpress.XamarinForms.Core.dll

        DevExpress.XamarinForms.CollectionView.dll

        <YourAppName>.Android

        (A project that contains Android-specific code)

        DevExpress.XamarinForms.CollectionView.Android.dll

        DevExpress.Xamarin.Android.CollectionView.dll

        <YourAppName>.iOS

        (A project that contains iOS-specific code)

        DevExpress.XamarinForms.CollectionView.iOS.dll

        DevExpress.Xamarin.iOS.CollectionView.dll

        NOTE

        These files are in the <DevExpress.Xamarin bundle>/Binaries directory. Ensure the downloaded <DevExpress.Xamarin> bundle was unzipped.

  2. Add the initialization code to your projects.

    • In the AppDelegate.cs file of the iOS project, before the LoadApplication method call:

      DevExpress.XamarinForms.CollectionView.iOS.Initializer.Init();
      
    • In the MainPage.xaml.cs file of the project with the shared code, before the InitializeComponent method call:

      DevExpress.XamarinForms.CollectionView.Initializer.Init();
      
  3. Add the following namespace to the XAML markup or C# file in which you create a CollectionView:

    xmlns:dxcv="http://schemas.devexpress.com/xamarin/2014/forms/collectionview"
    
  4. Create a DXCollectionView instance in XAML markup or C# code:

    <ContentPage
    xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    x:Class="CollectionViewExample.MainPage"
    xmlns:ios="clr-namespace:Xamarin.Forms.PlatformConfiguration.iOSSpecific;assembly=Xamarin.Forms.Core"
    xmlns:dxcv="http://schemas.devexpress.com/xamarin/2014/forms/collectionview"
    ios:Page.UseSafeArea="True">
        <dxcv:DXCollectionView x:Name="collectionView">
        </dxcv:DXCollectionView>
    </ContentPage>
    

The Getting Started section contains examples with instructions on how to bind a collection view to a data source, specify the item template, and manage data.