Skip to content

Commit cf76c0c

Browse files
author
Elena Dvoryadkina
committed
DevExpress Data Grid for .NET MAUI Preview 8
1 parent 921c159 commit cf76c0c

19 files changed

+472
-265
lines changed

CS/DataGridExample.sln

+7-9
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,25 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio Version 17
4-
VisualStudioVersion = 17.0.31521.260
4+
VisualStudioVersion = 17.0.31710.8
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DataGridExample", "DataGridExample\DataGridExample.csproj", "{64998071-DA7E-4D0E-BEF7-A71A0D4234B8}"
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DataGridExample", "DataGridExample\DataGridExample.csproj", "{47C222FE-1FD9-4D41-8085-97C5355E3EDF}"
77
EndProject
88
Global
99
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1010
Debug|Any CPU = Debug|Any CPU
1111
Release|Any CPU = Release|Any CPU
1212
EndGlobalSection
1313
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14-
{64998071-DA7E-4D0E-BEF7-A71A0D4234B8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15-
{64998071-DA7E-4D0E-BEF7-A71A0D4234B8}.Debug|Any CPU.Build.0 = Debug|Any CPU
16-
{64998071-DA7E-4D0E-BEF7-A71A0D4234B8}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
17-
{64998071-DA7E-4D0E-BEF7-A71A0D4234B8}.Release|Any CPU.ActiveCfg = Release|Any CPU
18-
{64998071-DA7E-4D0E-BEF7-A71A0D4234B8}.Release|Any CPU.Build.0 = Release|Any CPU
19-
{64998071-DA7E-4D0E-BEF7-A71A0D4234B8}.Release|Any CPU.Deploy.0 = Release|Any CPU
14+
{47C222FE-1FD9-4D41-8085-97C5355E3EDF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{47C222FE-1FD9-4D41-8085-97C5355E3EDF}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{47C222FE-1FD9-4D41-8085-97C5355E3EDF}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{47C222FE-1FD9-4D41-8085-97C5355E3EDF}.Release|Any CPU.Build.0 = Release|Any CPU
2018
EndGlobalSection
2119
GlobalSection(SolutionProperties) = preSolution
2220
HideSolutionNode = FALSE
2321
EndGlobalSection
2422
GlobalSection(ExtensibilityGlobals) = postSolution
25-
SolutionGuid = {61F7FB11-1E47-470C-91E2-47F8143E1572}
23+
SolutionGuid = {C4463F5D-AB9F-4B33-B649-29231BB2348A}
2624
EndGlobalSection
2725
EndGlobal

CS/DataGridExample/App.xaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44
xmlns:local="clr-namespace:DataGridExample"
55
x:Class="DataGridExample.App"
66
windows:Application.ImageDirectory="Assets">
7-
7+
<Application.Resources>
8+
</Application.Resources>
89
</Application>

CS/DataGridExample/App.xaml.cs

+8-8
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55

66
namespace DataGridExample
77
{
8-
public partial class App : Application
9-
{
10-
public App()
11-
{
12-
InitializeComponent();
8+
public partial class App : Application
9+
{
10+
public App()
11+
{
12+
InitializeComponent();
1313

14-
MainPage = new MainPage();
15-
}
16-
}
14+
MainPage = new MainPage();
15+
}
16+
}
1717
}

CS/DataGridExample/DataGridExample.csproj

+31-15
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<!-- Android -->
5-
<TargetFrameworks>net6.0-android</TargetFrameworks>
4+
<TargetFrameworks>net6.0-android;net6.0-ios</TargetFrameworks>
65
<OutputType>Exe</OutputType>
6+
<RootNamespace>DataGridExample</RootNamespace>
77
<UseMaui>true</UseMaui>
88
<SingleProject>true</SingleProject>
9-
<RootNamespace>DataGridExample</RootNamespace>
9+
<EnablePreviewMsixTooling>true</EnablePreviewMsixTooling>
1010

1111
<!-- Display name -->
1212
<ApplicationTitle>DataGridExample</ApplicationTitle>
@@ -17,6 +17,9 @@
1717
<!-- Versions -->
1818
<ApplicationVersion>1.0</ApplicationVersion>
1919
<AndroidVersionCode>1</AndroidVersionCode>
20+
21+
<!-- Required for C# Hot Reload -->
22+
<UseInterpreter Condition="'$(Configuration)' == 'Debug'">True</UseInterpreter>
2023
</PropertyGroup>
2124

2225
<ItemGroup>
@@ -33,6 +36,30 @@
3336
<MauiFont Include="Resources\Fonts\*" />
3437
</ItemGroup>
3538

39+
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0-ios'">
40+
<PackageReference Include="DevExpress.Maui.DataGrid">
41+
<Version>21.2.1-pre-21272</Version>
42+
</PackageReference>
43+
</ItemGroup>
44+
45+
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0-android'">
46+
<PackageReference Include="DevExpress.Maui.DataGrid">
47+
<Version>21.2.1-pre-21272</Version>
48+
</PackageReference>
49+
</ItemGroup>
50+
51+
<ItemGroup>
52+
<None Remove="Images\Andrew_Fuller.jpg" />
53+
<None Remove="Images\Anne_Dodsworth.jpg" />
54+
<None Remove="Images\Janet_Leverling.jpg" />
55+
<None Remove="Images\Laura_Callahan.jpg" />
56+
<None Remove="Images\Margaret_Peacock.jpg" />
57+
<None Remove="Images\Michael_Suyama.jpg" />
58+
<None Remove="Images\Nancy_Davolio.jpg" />
59+
<None Remove="Images\Robert_King.jpg" />
60+
<None Remove="Images\Steven_Buchanan.jpg" />
61+
</ItemGroup>
62+
3663
<ItemGroup>
3764
<EmbeddedResource Include="Images\Andrew_Fuller.jpg" />
3865
<EmbeddedResource Include="Images\Anne_Dodsworth.jpg" />
@@ -45,15 +72,4 @@
4572
<EmbeddedResource Include="Images\Steven_Buchanan.jpg" />
4673
</ItemGroup>
4774

48-
<ItemGroup>
49-
<PackageReference Include="DevExpress.Maui.DataGrid" Version="21.2.1-pre-21231" />
50-
</ItemGroup>
51-
52-
<PropertyGroup>
53-
<InvariantGlobalization Condition="$(TargetFramework.Contains('-maccatalyst'))">true</InvariantGlobalization>
54-
<RuntimeIdentifier Condition="$(TargetFramework.Contains('-ios'))">iossimulator-x64</RuntimeIdentifier>
55-
<RuntimeIdentifier Condition="$(TargetFramework.Contains('-maccatalyst'))">maccatalyst-x64</RuntimeIdentifier>
56-
<UseInterpreter Condition="$(TargetFramework.Contains('-android'))">False</UseInterpreter>
57-
</PropertyGroup>
58-
5975
</Project>

CS/DataGridExample/MainPage.xaml

+22-20
Original file line numberDiff line numberDiff line change
@@ -6,35 +6,37 @@
66
<ContentPage.BindingContext>
77
<local:EmployeeDataViewModel/>
88
</ContentPage.BindingContext>
9-
<dxg:DataGridView ItemsSource="{Binding Employees}"
10-
AllowDragDropRows="True">
11-
<dxg:DataGridView.Columns>
12-
<dxg:ImageColumn FieldName="Photo" Width="100"/>
9+
<dxg:DataGridView ItemsSource="{Binding Employees}"
10+
EditorShowMode="DoubleTap"
11+
AllowDragDropRows="True">
12+
<dxg:DataGridView.Columns>
13+
<dxg:ImageColumn FieldName="Photo" Width="100"/>
1314
<dxg:TemplateColumn FieldName="Name" Caption="Employee" MinWidth="200">
1415
<dxg:TemplateColumn.DisplayTemplate>
1516
<DataTemplate>
1617
<Grid VerticalOptions="Center" Padding="15, 0, 0, 0" RowDefinitions="Auto, Auto, Auto">
1718
<Label Text="{Binding Item.Name}" FontSize="18" FontAttributes="Bold"
18-
TextColor="{DynamicResource GridCellFontColor}" Grid.Row="0" />
19+
TextColor="{DynamicResource GridCellFontColor}" Grid.Row="0" />
1920
<Label Text="{Binding Item.Position, StringFormat = 'Job Title: {0}'}"
20-
FontSize="Small" TextColor="{DynamicResource GridCellFontColor}"
21-
Grid.Row="1"/>
21+
FontSize="Small" TextColor="{DynamicResource GridCellFontColor}"
22+
Grid.Row="1"/>
2223
<Label Text="{Binding Item.HireDate, StringFormat = 'Hire Date: {0:d}'}"
23-
FontSize="Small" TextColor="{DynamicResource GridCellFontColor}"
24-
Grid.Row="2" />
24+
FontSize="Small" TextColor="{DynamicResource GridCellFontColor}"
25+
Grid.Row="2" />
2526
</Grid>
2627
</DataTemplate>
2728
</dxg:TemplateColumn.DisplayTemplate>
2829
</dxg:TemplateColumn>
29-
30-
<dxg:TemplateColumn FieldName="Access" Caption="Access Level" Width="90">
31-
<dxg:TemplateColumn.DisplayTemplate>
32-
<DataTemplate>
33-
<Label Text="{Binding Value}" TextColor="{DynamicResource GridCellFontColor}"
34-
Grid.Row="0" Padding="14, 21, 14, 21" VerticalOptions="Center"/>
35-
</DataTemplate>
36-
</dxg:TemplateColumn.DisplayTemplate>
37-
</dxg:TemplateColumn>
30+
<dxg:TextColumn FieldName="Phone"
31+
MinWidth="130" VerticalContentAlignment="Center" />
32+
<dxg:TextColumn FieldName="Address"
33+
MinWidth="150" VerticalContentAlignment="Center" />
34+
<dxg:DateColumn FieldName="BirthDate"
35+
MinWidth="120" DisplayFormat="d" VerticalContentAlignment="Center"/>
36+
<dxg:ComboBoxColumn FieldName="Access" Caption="Access Level"
37+
MinWidth="140" VerticalContentAlignment="Center"/>
38+
<dxg:CheckBoxColumn FieldName="OnVacation"
39+
MinWidth="130" VerticalContentAlignment="Center"/>
3840
</dxg:DataGridView.Columns>
39-
</dxg:DataGridView>
40-
</ContentPage>
41+
</dxg:DataGridView>
42+
</ContentPage>

CS/DataGridExample/MainPage.xaml.cs

+11-9
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
using System;
2-
using Microsoft.Maui.Controls;
1+
using Microsoft.Maui.Controls;
2+
using Microsoft.Maui.Essentials;
3+
using System;
34

45
namespace DataGridExample
56
{
6-
public partial class MainPage : ContentPage
7-
{
8-
public MainPage()
9-
{
10-
InitializeComponent();
11-
}
12-
}
7+
public partial class MainPage : ContentPage
8+
{
9+
10+
public MainPage()
11+
{
12+
InitializeComponent();
13+
}
14+
}
1315
}

CS/DataGridExample/MauiProgram.cs

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using Microsoft.Maui;
2+
using Microsoft.Maui.Controls.Hosting;
3+
using Microsoft.Maui.Hosting;
4+
using DevExpress.Maui.DataGrid;
5+
using DevExpress.Maui.Editors;
6+
7+
namespace DataGridExample {
8+
public static class MauiProgram {
9+
public static MauiApp CreateMauiApp() {
10+
var builder = MauiApp.CreateBuilder();
11+
builder
12+
.ConfigureMauiHandlers((handlers) => {
13+
handlers.AddHandler<DataGridView, DataGridViewHandler>();
14+
handlers.AddHandler<TextEdit, TextEditHandler>();
15+
handlers.AddHandler<MultilineEdit, MultilineEditHandler>();
16+
handlers.AddHandler<DateEdit, DateEditHandler>();
17+
handlers.AddHandler<ComboBoxEdit, ComboBoxEditHandler>();
18+
handlers.AddHandler<CheckEdit, CheckEditHandler>();
19+
})
20+
.UseMauiApp<App>()
21+
.ConfigureFonts(fonts => {
22+
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
23+
});
24+
return builder.Build();
25+
}
26+
}
27+
}

CS/DataGridExample/Model.cs

+50-12
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
using System;
2-
using System.Collections.ObjectModel;
1+
using System.Collections.ObjectModel;
32
using Microsoft.Maui.Controls;
3+
using System;
44

55
namespace DataGridExample {
66
public enum AccessLevel {
@@ -27,78 +27,116 @@ public string Name {
2727
public Employee(string name) {
2828
this.Name = name;
2929
}
30-
3130
public ImageSource Photo { get; set; }
31+
public DateTime BirthDate { get; set; }
3232
public DateTime HireDate { get; set; }
3333
public string Position { get; set; }
34+
public string Address { get; set; }
3435
public string Phone { get; set; }
3536
public AccessLevel Access { get; set; }
37+
public bool OnVacation { get; set; }
3638
}
3739

3840
public class EmployeeData {
3941
void GenerateEmployees() {
4042
ObservableCollection<Employee> result = new ObservableCollection<Employee>();
4143
result.Add(
4244
new Employee("Nancy Davolio") {
45+
BirthDate = new DateTime(1978, 12, 8),
4346
HireDate = new DateTime(2005, 5, 1),
4447
Position = "Sales Representative",
45-
Access = AccessLevel.User
48+
Address = "98122, 507 - 20th Ave. E. Apt. 2A, Seattle WA, USA",
49+
Phone = "(206) 555-9857",
50+
Access = AccessLevel.User,
51+
OnVacation = false
4652
}
4753
);
4854
result.Add(
4955
new Employee("Andrew Fuller") {
56+
BirthDate = new DateTime(1965, 2, 19),
5057
HireDate = new DateTime(1992, 8, 14),
5158
Position = "Vice President, Sales",
52-
Access = AccessLevel.Admin
59+
Address = "98401, 908 W. Capital Way, Tacoma WA, USA",
60+
Phone = "(206) 555-9482",
61+
Access = AccessLevel.Admin,
62+
OnVacation = false
5363
}
5464
);
5565
result.Add(
5666
new Employee("Janet Leverling") {
67+
BirthDate = new DateTime(1985, 8, 30),
5768
HireDate = new DateTime(2002, 4, 1),
5869
Position = "Sales Representative",
59-
Access = AccessLevel.User
70+
Address = "98033, 722 Moss Bay Blvd., Kirkland WA, USA",
71+
Phone = "(206) 555-3412",
72+
Access = AccessLevel.User,
73+
OnVacation = false
6074
}
6175
);
6276
result.Add(
6377
new Employee("Margaret Peacock") {
78+
BirthDate = new DateTime(1973, 9, 19),
6479
HireDate = new DateTime(1993, 5, 3),
6580
Position = "Sales Representative",
66-
Access = AccessLevel.User
81+
Address = "98052, 4110 Old Redmond Rd., Redmond WA, USA",
82+
Phone = "(206) 555-8122",
83+
Access = AccessLevel.User,
84+
OnVacation = false
6785
}
6886
);
6987
result.Add(
7088
new Employee("Steven Buchanan") {
89+
BirthDate = new DateTime(1955, 3, 4),
7190
HireDate = new DateTime(1993, 10, 17),
7291
Position = "Sales Manager",
73-
Access = AccessLevel.User
92+
Address = "SW1 8JR, 14 Garrett Hill, London, UK",
93+
Phone = "(71) 555-4848",
94+
Access = AccessLevel.User,
95+
OnVacation = true
7496
}
7597
);
7698
result.Add(
7799
new Employee("Michael Suyama") {
100+
BirthDate = new DateTime(1981, 7, 2),
78101
HireDate = new DateTime(1999, 10, 17),
79102
Position = "Sales Representative",
80-
Access = AccessLevel.User
103+
Address = "EC2 7JR, Coventry House Miner Rd., London, UK",
104+
Phone = "(71) 555-7773",
105+
Access = AccessLevel.User,
106+
OnVacation = false
81107
}
82108
);
83109
result.Add(
84110
new Employee("Robert King") {
111+
BirthDate = new DateTime(1960, 5, 29),
85112
HireDate = new DateTime(1994, 1, 2),
86113
Position = "Sales Representative",
87-
Access = AccessLevel.User
114+
Address = "RG1 9SP, Edgeham Hollow Winchester Way, London, UK",
115+
Phone = "(71) 555-5598",
116+
Access = AccessLevel.User,
117+
OnVacation = false
88118
}
89119
);
90120
result.Add(
91121
new Employee("Laura Callahan") {
122+
BirthDate = new DateTime(1985, 1, 9),
92123
HireDate = new DateTime(2004, 3, 5),
93124
Position = "Inside Sales Coordinator",
94-
Access = AccessLevel.User
125+
Address = "98105, 4726 - 11th Ave. N.E., Seattle WA, USA",
126+
Phone = "(206) 555-1189",
127+
Access = AccessLevel.User,
128+
OnVacation = true
95129
}
96130
);
97131
result.Add(
98132
new Employee("Anne Dodsworth") {
133+
BirthDate = new DateTime(1980, 1, 27),
99134
HireDate = new DateTime(2004, 11, 15),
100135
Position = "Sales Representative",
101-
Access = AccessLevel.User
136+
Address = "WG2 7LT, 7 Houndstooth Rd., London, UK",
137+
Phone = "(71) 555-4444",
138+
Access = AccessLevel.User,
139+
OnVacation = false
102140
}
103141
);
104142
Employees = result;
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
3-
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="30" />
3+
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="31" />
44
<application android:allowBackup="true" android:icon="@mipmap/appicon" android:roundIcon="@mipmap/appicon_round" android:supportsRtl="true"></application>
55
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
66
</manifest>

0 commit comments

Comments
 (0)