Skip to content

Commit 82070d6

Browse files
.NET MAUI ListView sample
1 parent 34a2c2d commit 82070d6

39 files changed

+1171
-2
lines changed

MauiProject.sln

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.0.31611.283
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MauiProject", "MauiProject\MauiProject.csproj", "{7F916BF4-E70C-459E-8E8D-FDD28F99ED10}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{7F916BF4-E70C-459E-8E8D-FDD28F99ED10}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{7F916BF4-E70C-459E-8E8D-FDD28F99ED10}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{7F916BF4-E70C-459E-8E8D-FDD28F99ED10}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
17+
{7F916BF4-E70C-459E-8E8D-FDD28F99ED10}.Release|Any CPU.ActiveCfg = Release|Any CPU
18+
{7F916BF4-E70C-459E-8E8D-FDD28F99ED10}.Release|Any CPU.Build.0 = Release|Any CPU
19+
{7F916BF4-E70C-459E-8E8D-FDD28F99ED10}.Release|Any CPU.Deploy.0 = Release|Any CPU
20+
EndGlobalSection
21+
GlobalSection(SolutionProperties) = preSolution
22+
HideSolutionNode = FALSE
23+
EndGlobalSection
24+
GlobalSection(ExtensibilityGlobals) = postSolution
25+
SolutionGuid = {61F7FB11-1E47-470C-91E2-47F8143E1572}
26+
EndGlobalSection
27+
EndGlobal

MauiProject/App.xaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version = "1.0" encoding = "UTF-8" ?>
2+
<Application xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
4+
xmlns:local="clr-namespace:MauiProject"
5+
x:Class="MauiProject.App">
6+
<Application.Resources>
7+
<ResourceDictionary>
8+
<ResourceDictionary.MergedDictionaries>
9+
<ResourceDictionary Source="Resources/Styles/Colors.xaml" />
10+
<ResourceDictionary Source="Resources/Styles/Styles.xaml" />
11+
</ResourceDictionary.MergedDictionaries>
12+
</ResourceDictionary>
13+
</Application.Resources>
14+
</Application>

MauiProject/App.xaml.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
namespace MauiProject;
2+
3+
public partial class App : Application
4+
{
5+
public App()
6+
{
7+
Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("Mgo+DSMBMAY9C3t2VVhiQlFaclxJVHxOYVF2R2FJeVRzdV9HaUwgOX1dQl9hSXZTfkVrW3tacHdWRWk= ");
8+
InitializeComponent();
9+
10+
MainPage = new AppShell();
11+
}
12+
}

MauiProject/AppShell.xaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<Shell
3+
x:Class="MauiProject.AppShell"
4+
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
5+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
6+
xmlns:local="clr-namespace:MauiProject"
7+
Shell.FlyoutBehavior="Disabled">
8+
9+
<ShellContent
10+
Title="Home"
11+
ContentTemplate="{DataTemplate local:MainPage}"
12+
Route="MainPage" />
13+
14+
</Shell>

MauiProject/AppShell.xaml.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace MauiProject;
2+
3+
public partial class AppShell : Shell
4+
{
5+
public AppShell()
6+
{
7+
InitializeComponent();
8+
}
9+
}

MauiProject/BookInfo.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace MauiProject
8+
{
9+
public class BookInfo
10+
{
11+
public string BookName { get; set; }
12+
public string BookDescription { get; set; }
13+
}
14+
}

MauiProject/BookViewModel.cs

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Collections.ObjectModel;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
8+
namespace MauiProject
9+
{
10+
public class BookViewModel
11+
{
12+
public ObservableCollection<string> Books { get; set; }
13+
14+
public ObservableCollection<BookInfo> BookDetails { get; set; }
15+
16+
public BookViewModel() {
17+
18+
BookDetails = new ObservableCollection<BookInfo>()
19+
{
20+
new BookInfo { BookName = "Object-Oriented Programming in C#", BookDescription = "Object-oriented programming uses objects to design programs" },
21+
new BookInfo { BookName = "C# Code Contracts", BookDescription = "Code Contracts provide a way to convey code assumptions" },
22+
new BookInfo { BookName = "Machine Learning Using C#", BookDescription = "Learn several different approaches to applying machine learning" },
23+
new BookInfo { BookName = "Neural Networks Using C#", BookDescription = "Neural networks are an exciting field of software development" },
24+
new BookInfo { BookName = "Visual Studio Code", BookDescription = "It is a powerful tool for editing code and serves for end-to-end programming" },
25+
new BookInfo { BookName = "Android Programming", BookDescription = "It provides a useful overview of the Android application life cycle" },
26+
new BookInfo { BookName = "iOS Succinctly", BookDescription = "It is for developers looking to step into frightening world of iPhone" },
27+
new BookInfo { BookName = "Visual Studio 2015", BookDescription = "The new version of the widely-used integrated development environment" },
28+
};
29+
30+
Books = new ObservableCollection<string>
31+
{
32+
".NET MAUI Guidelines",
33+
"Introduction to .NET MAUI",
34+
"Learn .NET MAUI",
35+
".NET MAUI First look",
36+
"What is .NET MAUI",
37+
"Learn .NET Community Toolkit",
38+
"A Journey to .NET MAUI",
39+
".NET MAUI community stand up",
40+
".NET MAUI samples demo",
41+
".NET MAUI community samples",
42+
"Sample browser",
43+
"com.syncfusion.samplebrowser.maui.Signed",
44+
"com.android.chrome",
45+
"com.android.vending",
46+
"com.android.mediacenter",
47+
"Syncfusion Gallery",
48+
"Syncfusion Orientation Program"
49+
};
50+
}
51+
}
52+
}

MauiProject/MainPage.xaml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
4+
xmlns:sf="clr-namespace:Syncfusion.Maui.ListView;assembly=Syncfusion.Maui.ListView"
5+
xmlns:local="clr-namespace:MauiProject"
6+
x:Class="MauiProject.MainPage">
7+
<ContentPage.BindingContext>
8+
<local:BookViewModel></local:BookViewModel>
9+
</ContentPage.BindingContext>
10+
11+
<sf:SfListView ItemsSource="{Binding BookDetails}" ItemSize="140"
12+
SelectionMode="None">
13+
<sf:SfListView.ItemsLayout>
14+
<sf:GridLayout SpanCount="2"></sf:GridLayout>
15+
</sf:SfListView.ItemsLayout>
16+
<sf:SfListView.HeaderTemplate>
17+
<DataTemplate>
18+
<Grid Background="#4CA1FE" HeightRequest="45">
19+
<Label Text="Book List"
20+
FontAttributes="Bold"
21+
TextColor="White"
22+
HorizontalTextAlignment="Center"
23+
VerticalTextAlignment="Center"></Label>
24+
</Grid>
25+
</DataTemplate>
26+
</sf:SfListView.HeaderTemplate>
27+
<sf:SfListView.FooterTemplate>
28+
<DataTemplate>
29+
<Grid Background="#4CA1FE" HeightRequest="45">
30+
<Label Text="Syncfusion | All rights reserved"
31+
FontAttributes="Bold"
32+
TextColor="White"
33+
HorizontalTextAlignment="Center"
34+
VerticalTextAlignment="Center"></Label>
35+
</Grid>
36+
</DataTemplate>
37+
</sf:SfListView.FooterTemplate>
38+
<sf:SfListView.ItemTemplate>
39+
<DataTemplate>
40+
<Grid>
41+
<Grid.RowDefinitions>
42+
<RowDefinition Height="0.4*"></RowDefinition>
43+
<RowDefinition Height="0.6*"></RowDefinition>
44+
</Grid.RowDefinitions>
45+
<Label Text="{Binding BookName}"
46+
FontAttributes="Bold"
47+
TextColor="CadetBlue"
48+
FontSize="21"></Label>
49+
<Label Text="{Binding BookDescription}"
50+
Grid.Row="1"
51+
FontSize="15"></Label>
52+
</Grid>
53+
</DataTemplate>
54+
</sf:SfListView.ItemTemplate>
55+
</sf:SfListView>
56+
</ContentPage>

MauiProject/MainPage.xaml.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
namespace MauiProject;
2+
3+
public partial class MainPage : ContentPage
4+
{
5+
6+
7+
public MainPage()
8+
{
9+
InitializeComponent();
10+
}
11+
}
12+

MauiProject/MauiProgram.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using Microsoft.Extensions.Logging;
2+
using Syncfusion.Maui.Core.Hosting;
3+
namespace MauiProject;
4+
5+
public static class MauiProgram
6+
{
7+
public static MauiApp CreateMauiApp()
8+
{
9+
var builder = MauiApp.CreateBuilder();
10+
builder
11+
.UseMauiApp<App>()
12+
.ConfigureSyncfusionCore()
13+
.ConfigureFonts(fonts =>
14+
{
15+
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
16+
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
17+
});
18+
19+
#if DEBUG
20+
builder.Logging.AddDebug();
21+
#endif
22+
23+
return builder.Build();
24+
}
25+
}

0 commit comments

Comments
 (0)