The requested page is not available for the requested platform. You are viewing the content for Default platform.

Create a Solution with the DevExpress Grid Component in Visual Studio for Mac

Important

This documentation topic describes legacy technology. We no longer develop new functionality for the GridControl and suggest that you use the new DataGridView control instead.

This topic explains how to create a new Xamarin.Forms cross-platform solution in Visual Studio for Mac, and how to add the DevExpress Grid component to your application using the DevExpress Grid NuGet package.

Create a Solution

  1. Start Visual Studio for Mac and select File | New Solution... in the main menu. In the invoked New Project dialog, switch to the Multiplatform | App section and select the Blank Forms App template. Click Next.

    Grid_VSForMac_CreateApp_1

  2. Name the application HelloGrid, select Android and iOS target platforms, and set .NET Standard as the code sharing strategy. Click Next.

    Grid_18_1_2_VSForMac_CreateApp_2

  3. Specify the solution's name and location. Click Create.

    Grid_18_1_2_VSForMac_CreateApp_3

The newly created solution contains the following projects:

  • HelloGrid - A class library that contains the shared code and UI;
  • HelloGrid.Droid - A project that contains Android specific code and serves as the Android application's entry point;
  • HelloGrid.iOS - A project that contains iOS specific code and serves as the iOS application's entry point.

Add the DevExpress Grid Component to a Solution

Add the DevExpress Grid NuGet package from NuGet.org to the solution's projects:

  1. In a project, right-click the Dependencies | NuGet folder and select Add Packages...

    Grid_VSForMac_AddNuGet

  2. In the invoked Add Packages dialog, search for DevExpress.Mobile.Grid in the nuget.org package source and click Add Package.

    Important

    Add Xamarin.Forms v3.4.0.1008975 to the project before you add the DevExpress Grid package. The DevExpress Grid component supports this Xamarin.Forms version only.

    Grid_18_1_3_VSForMac_AddNuGetPackage

Initialize the DevExpress Grid Component

Add the following initialization code to your Android (MainActivity.cs) and iOS (AppDelegate.cs) projects before the LoadApplication method call:

DevExpress.Mobile.Forms.Init ();

Add Namespaces

Add the following namespace to a XAML markup or C# file in which a Grid instance is created:

xmlns:dxGrid="clr-namespace:DevExpress.Mobile.DataGrid;assembly=DevExpress.Mobile.Grid.v18.2"
using DevExpress.Mobile.DataGrid;

Create a Grid Instance

You can create a GridControl instance using XAML markup...

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" 
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
             x:Class="HelloGrid.MainPage"
             xmlns:dxGrid="clr-namespace:DevExpress.Mobile.DataGrid;assembly=DevExpress.Mobile.Grid.v18.2">
    <dxGrid:GridControl x:Name="grid">
    </dxGrid:GridControl>
</ContentPage>

...or C# code.

using System;
using Xamarin.Forms;
using DevExpress.Mobile.DataGrid;

namespace HelloGrid
{
    public class App : Application
    {
        public App ()
        {
            GridControl grid = new GridControl ();
            MainPage = new ContentPage {
                Content = grid,
            };
        }
    }
}

The Getting Started section provides an example with detailed instructions on how to create an application with a grid bound to a data source and adjust various settings.