Skip to content

Commit 385ca9a

Browse files
Merge pull request #1 from JayashreeRavishankar/main
MAUI-1519 : How to show empty message when listview has no items in MAUI
2 parents 3bba238 + b4699ed commit 385ca9a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+930
-0
lines changed

ListViewDemo.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}") = "ListViewDemo", "ListViewDemo\ListViewDemo.csproj", "{E214FF70-3140-44E6-A1E6-B0B19430AF88}"
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+
{E214FF70-3140-44E6-A1E6-B0B19430AF88}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{E214FF70-3140-44E6-A1E6-B0B19430AF88}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{E214FF70-3140-44E6-A1E6-B0B19430AF88}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
17+
{E214FF70-3140-44E6-A1E6-B0B19430AF88}.Release|Any CPU.ActiveCfg = Release|Any CPU
18+
{E214FF70-3140-44E6-A1E6-B0B19430AF88}.Release|Any CPU.Build.0 = Release|Any CPU
19+
{E214FF70-3140-44E6-A1E6-B0B19430AF88}.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

ListViewDemo/App.xaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<Application xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
2+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
3+
xmlns:local="clr-namespace:ListViewDemo"
4+
x:Class="ListViewDemo.App">
5+
<Application.Resources>
6+
<ResourceDictionary>
7+
8+
<Color x:Key="PrimaryColor">#512bdf</Color>
9+
<Color x:Key="SecondaryColor">White</Color>
10+
11+
<Style TargetType="Label">
12+
<Setter Property="TextColor" Value="{DynamicResource PrimaryColor}" />
13+
<Setter Property="FontFamily" Value="OpenSansRegular" />
14+
</Style>
15+
16+
<Style TargetType="Button">
17+
<Setter Property="TextColor" Value="{DynamicResource SecondaryColor}" />
18+
<Setter Property="FontFamily" Value="OpenSansRegular" />
19+
<Setter Property="BackgroundColor" Value="{DynamicResource PrimaryColor}" />
20+
<Setter Property="Padding" Value="14,10" />
21+
</Style>
22+
23+
</ResourceDictionary>
24+
</Application.Resources>
25+
</Application>

ListViewDemo/App.xaml.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
namespace ListViewDemo;
2+
3+
public partial class App : Application
4+
{
5+
public App()
6+
{
7+
InitializeComponent();
8+
9+
MainPage = new MainPage();
10+
}
11+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Globalization;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
8+
namespace ListViewDemo
9+
{
10+
public class VisibilityConverter : IValueConverter
11+
{
12+
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
13+
{
14+
return !(bool)value;
15+
}
16+
17+
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
18+
{
19+
return value;
20+
}
21+
}
22+
}

ListViewDemo/ListViewDemo.csproj

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFrameworks>net6.0-android;net6.0-ios;net6.0-maccatalyst</TargetFrameworks>
5+
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows')) and '$(MSBuildRuntimeType)' == 'Full'">$(TargetFrameworks);net6.0-windows10.0.19041</TargetFrameworks>
6+
<OutputType>Exe</OutputType>
7+
<RootNamespace>ListViewDemo</RootNamespace>
8+
<UseMaui>true</UseMaui>
9+
<SingleProject>true</SingleProject>
10+
<ImplicitUsings>enable</ImplicitUsings>
11+
<EnablePreviewMsixTooling>true</EnablePreviewMsixTooling>
12+
13+
<!-- Display name -->
14+
<ApplicationTitle>ListViewDemo</ApplicationTitle>
15+
16+
<!-- App Identifier -->
17+
<ApplicationId>com.companyname.listviewdemo</ApplicationId>
18+
19+
<!-- Versions -->
20+
<ApplicationVersion>1</ApplicationVersion>
21+
22+
<!-- Required for C# Hot Reload -->
23+
<UseInterpreter Condition="'$(Configuration)' == 'Debug'">True</UseInterpreter>
24+
25+
<SupportedOSPlatformVersion Condition="'$(TargetFramework)' == 'net6.0-ios'">14.2</SupportedOSPlatformVersion>
26+
<SupportedOSPlatformVersion Condition="'$(TargetFramework)' == 'net6.0-maccatalyst'">14.0</SupportedOSPlatformVersion>
27+
<SupportedOSPlatformVersion Condition="'$(TargetFramework)' == 'net6.0-android'">21.0</SupportedOSPlatformVersion>
28+
<SupportedOSPlatformVersion Condition="$(TargetFramework.Contains('-windows'))">10.0.17763.0</SupportedOSPlatformVersion>
29+
<TargetPlatformMinVersion Condition="$(TargetFramework.Contains('-windows'))">10.0.17763.0</TargetPlatformMinVersion>
30+
</PropertyGroup>
31+
32+
<ItemGroup>
33+
<!-- App Icon -->
34+
<MauiIcon Include="Resources\appicon.svg" ForegroundFile="Resources\appiconfg.svg" Color="#512BD4" />
35+
36+
<!-- Splash Screen -->
37+
<MauiSplashScreen Include="Resources\appiconfg.svg" Color="#512BD4" />
38+
39+
<!-- Images -->
40+
<MauiImage Include="Resources\Images\*" />
41+
42+
<!-- Custom Fonts -->
43+
<MauiFont Include="Resources\Fonts\*" />
44+
45+
<!-- Raw Assets (also remove the "Resources\Raw" prefix) -->
46+
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
47+
</ItemGroup>
48+
49+
<ItemGroup Condition="$(TargetFramework.Contains('-windows'))">
50+
<!-- Required - WinUI does not yet have buildTransitive for everything -->
51+
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.0.0" />
52+
<PackageReference Include="Microsoft.Graphics.Win2D" Version="1.0.0.30" />
53+
</ItemGroup>
54+
55+
<ItemGroup>
56+
<None Remove="Resources\Fonts\Roboto-Medium.ttf" />
57+
<None Remove="Resources\Fonts\Roboto-Regular.ttf" />
58+
<None Remove="Resources\Images\image0.png" />
59+
<None Remove="Resources\Images\image1.png" />
60+
<None Remove="Resources\Images\image10.png" />
61+
<None Remove="Resources\Images\image11.png" />
62+
<None Remove="Resources\Images\image12.png" />
63+
<None Remove="Resources\Images\image13.png" />
64+
<None Remove="Resources\Images\image14.png" />
65+
<None Remove="Resources\Images\image15.png" />
66+
<None Remove="Resources\Images\image16.png" />
67+
<None Remove="Resources\Images\image17.png" />
68+
<None Remove="Resources\Images\image18.png" />
69+
<None Remove="Resources\Images\image19.png" />
70+
<None Remove="Resources\Images\image2.png" />
71+
<None Remove="Resources\Images\image20.png" />
72+
<None Remove="Resources\Images\image21.png" />
73+
<None Remove="Resources\Images\image22.png" />
74+
<None Remove="Resources\Images\image23.png" />
75+
<None Remove="Resources\Images\image24.png" />
76+
<None Remove="Resources\Images\image25.png" />
77+
<None Remove="Resources\Images\image26.png" />
78+
<None Remove="Resources\Images\image27.png" />
79+
<None Remove="Resources\Images\image28.png" />
80+
<None Remove="Resources\Images\image3.png" />
81+
<None Remove="Resources\Images\image4.png" />
82+
<None Remove="Resources\Images\image5.png" />
83+
<None Remove="Resources\Images\image6.png" />
84+
<None Remove="Resources\Images\image7.png" />
85+
<None Remove="Resources\Images\image8.png" />
86+
<None Remove="Resources\Images\image9.png" />
87+
</ItemGroup>
88+
89+
<ItemGroup>
90+
<PackageReference Include="Syncfusion.Maui.ListView" Version="19.4.55-preview" />
91+
</ItemGroup>
92+
93+
<PropertyGroup Condition="$(TargetFramework.Contains('-windows'))">
94+
<OutputType>WinExe</OutputType>
95+
<RuntimeIdentifier>win10-x64</RuntimeIdentifier>
96+
</PropertyGroup>
97+
98+
</Project>

ListViewDemo/MauiProgram.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
namespace ListViewDemo;
2+
3+
public static class MauiProgram
4+
{
5+
public static MauiApp CreateMauiApp()
6+
{
7+
var builder = MauiApp.CreateBuilder();
8+
builder
9+
.UseMauiApp<App>()
10+
.ConfigureFonts(fonts =>
11+
{
12+
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
13+
fonts.AddFont("Roboto-Medium.ttf", "Roboto-Medium");
14+
fonts.AddFont("Roboto-Regular.ttf", "Roboto-Regular");
15+
});
16+
17+
return builder.Build();
18+
}
19+
}
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.ComponentModel;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
8+
namespace ListViewDemo
9+
{
10+
public class ListViewContactsInfo : INotifyPropertyChanged
11+
{
12+
#region Fields
13+
14+
private string contactName;
15+
private string contactNo;
16+
private ImageSource image;
17+
private string contactType;
18+
19+
#endregion
20+
21+
#region Constructor
22+
public ListViewContactsInfo()
23+
{
24+
25+
}
26+
27+
#endregion
28+
29+
#region Public Properties
30+
31+
public string ContactName
32+
{
33+
get { return this.contactName; }
34+
set
35+
{
36+
this.contactName = value;
37+
RaisePropertyChanged("ContactName");
38+
}
39+
}
40+
41+
public string ContactNumber
42+
{
43+
get { return contactNo; }
44+
set
45+
{
46+
this.contactNo = value;
47+
RaisePropertyChanged("ContactNumber");
48+
}
49+
}
50+
51+
public string ContactType
52+
{
53+
get { return contactType; }
54+
set
55+
{
56+
this.contactType = value;
57+
RaisePropertyChanged("ContactType");
58+
}
59+
}
60+
61+
public ImageSource ContactImage
62+
{
63+
get { return this.image; }
64+
set
65+
{
66+
this.image = value;
67+
this.RaisePropertyChanged("ContactImage");
68+
}
69+
}
70+
71+
#endregion
72+
73+
#region INotifyPropertyChanged implementation
74+
75+
public event PropertyChangedEventHandler PropertyChanged;
76+
77+
private void RaisePropertyChanged(String name)
78+
{
79+
if (PropertyChanged != null)
80+
this.PropertyChanged(this, new PropertyChangedEventArgs(name));
81+
}
82+
83+
#endregion
84+
}
85+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
3+
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="31" />
4+
<application android:allowBackup="true" android:icon="@mipmap/appicon" android:roundIcon="@mipmap/appicon_round" android:supportsRtl="true"></application>
5+
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
6+
</manifest>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using Android.App;
2+
using Android.Content.PM;
3+
using Android.OS;
4+
5+
namespace ListViewDemo;
6+
7+
[Activity(Theme = "@style/Maui.SplashTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize)]
8+
public class MainActivity : MauiAppCompatActivity
9+
{
10+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using Android.App;
2+
using Android.Runtime;
3+
4+
namespace ListViewDemo;
5+
6+
[Application]
7+
public class MainApplication : MauiApplication
8+
{
9+
public MainApplication(IntPtr handle, JniHandleOwnership ownership)
10+
: base(handle, ownership)
11+
{
12+
}
13+
14+
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
15+
}

0 commit comments

Comments
 (0)