Skip to content

Commit 70af0cf

Browse files
Merge pull request #1 from AnanthaLakshmiKannan/master
UG DOC 831881: Added sample for Listview - Itemsreordering - DragViewIndicator
2 parents 7e83947 + 84a7474 commit 70af0cf

Some content is hidden

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

41 files changed

+1340
-0
lines changed

ListViewMaui.sln

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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}") = "ListViewMaui", "ListViewMaui\ListViewMaui.csproj", "{A048F7BA-4478-4198-8D7A-B1F9EFC01B24}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
Release-Xml|Any CPU = Release-Xml|Any CPU
13+
EndGlobalSection
14+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
15+
{A048F7BA-4478-4198-8D7A-B1F9EFC01B24}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
16+
{A048F7BA-4478-4198-8D7A-B1F9EFC01B24}.Debug|Any CPU.Build.0 = Debug|Any CPU
17+
{A048F7BA-4478-4198-8D7A-B1F9EFC01B24}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
18+
{A048F7BA-4478-4198-8D7A-B1F9EFC01B24}.Release|Any CPU.ActiveCfg = Release|Any CPU
19+
{A048F7BA-4478-4198-8D7A-B1F9EFC01B24}.Release|Any CPU.Build.0 = Release|Any CPU
20+
{A048F7BA-4478-4198-8D7A-B1F9EFC01B24}.Release|Any CPU.Deploy.0 = Release|Any CPU
21+
{A048F7BA-4478-4198-8D7A-B1F9EFC01B24}.Release-Xml|Any CPU.ActiveCfg = Release|Any CPU
22+
{A048F7BA-4478-4198-8D7A-B1F9EFC01B24}.Release-Xml|Any CPU.Build.0 = Release|Any CPU
23+
{A048F7BA-4478-4198-8D7A-B1F9EFC01B24}.Release-Xml|Any CPU.Deploy.0 = Release|Any CPU
24+
EndGlobalSection
25+
GlobalSection(SolutionProperties) = preSolution
26+
HideSolutionNode = FALSE
27+
EndGlobalSection
28+
GlobalSection(ExtensibilityGlobals) = postSolution
29+
SolutionGuid = {61F7FB11-1E47-470C-91E2-47F8143E1572}
30+
EndGlobalSection
31+
EndGlobal

ListViewMaui/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:ListViewMaui"
5+
x:Class="ListViewMaui.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>

ListViewMaui/App.xaml.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
namespace ListViewMaui;
2+
3+
public partial class App : Application
4+
{
5+
public App()
6+
{
7+
8+
InitializeComponent();
9+
10+
MainPage = new MainPage();
11+
}
12+
}
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 ListViewMaui
9+
{
10+
public class InverseBoolConverter : 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+
}

ListViewMaui/ListViewMaui.csproj

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFrameworks>net7.0-android;net7.0-ios;net7.0-maccatalyst</TargetFrameworks>
5+
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net7.0-windows10.0.19041.0</TargetFrameworks>
6+
<!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
7+
<!-- <TargetFrameworks>$(TargetFrameworks);net7.0-tizen</TargetFrameworks> -->
8+
<OutputType>Exe</OutputType>
9+
<RootNamespace>ListViewMaui</RootNamespace>
10+
<UseMaui>true</UseMaui>
11+
<SingleProject>true</SingleProject>
12+
<ImplicitUsings>enable</ImplicitUsings>
13+
14+
<!-- Display name -->
15+
<ApplicationTitle>ListViewMaui</ApplicationTitle>
16+
17+
<!-- App Identifier -->
18+
<ApplicationId>com.companyname.listviewmaui</ApplicationId>
19+
<ApplicationIdGuid>e342990f-bcd0-4dc6-93fe-2532904df1f4</ApplicationIdGuid>
20+
21+
<!-- Versions -->
22+
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
23+
<ApplicationVersion>1</ApplicationVersion>
24+
25+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">11.0</SupportedOSPlatformVersion>
26+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">13.1</SupportedOSPlatformVersion>
27+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
28+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
29+
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
30+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion>
31+
</PropertyGroup>
32+
33+
<ItemGroup>
34+
<!-- App Icon -->
35+
<MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#512BD4" />
36+
37+
<!-- Splash Screen -->
38+
<MauiSplashScreen Include="Resources\Splash\splash.svg" Color="#512BD4" BaseSize="128,128" />
39+
40+
<!-- Images -->
41+
<MauiImage Include="Resources\Images\*" />
42+
<MauiImage Update="Resources\Images\dotnet_bot.svg" BaseSize="168,208" />
43+
44+
<!-- Custom Fonts -->
45+
<MauiFont Include="Resources\Fonts\*" />
46+
47+
<!-- Raw Assets (also remove the "Resources\Raw" prefix) -->
48+
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
49+
</ItemGroup>
50+
51+
<ItemGroup>
52+
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="7.0.0" />
53+
<PackageReference Include="Syncfusion.Maui.Core" Version="*" />
54+
<PackageReference Include="Syncfusion.Maui.DataSource" Version="*" />
55+
<PackageReference Include="Syncfusion.Maui.GridCommon" Version="*" />
56+
<PackageReference Include="Syncfusion.Maui.ListView" Version="*" />
57+
</ItemGroup>
58+
59+
</Project>

ListViewMaui/MainPage.xaml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
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:syncfusion="clr-namespace:Syncfusion.Maui.ListView;assembly=Syncfusion.Maui.ListView"
5+
xmlns:data="clr-namespace:Syncfusion.Maui.DataSource;assembly=Syncfusion.Maui.DataSource"
6+
xmlns:local="clr-namespace:ListViewMaui;assembly=ListViewMaui"
7+
x:Class="ListViewMaui.MainPage">
8+
9+
<ContentPage.Resources>
10+
<local:InverseBoolConverter x:Key="inverseBoolConverter" />
11+
</ContentPage.Resources>
12+
13+
<ContentPage.BindingContext>
14+
<local:ViewModel />
15+
</ContentPage.BindingContext>
16+
17+
<Grid RowSpacing="0">
18+
<Grid.RowDefinitions>
19+
<RowDefinition Height="40" />
20+
<RowDefinition Height="*" />
21+
</Grid.RowDefinitions>
22+
<Grid BackgroundColor="#2196F3">
23+
<Label Text="To Do Items" x:Name="headerLabel" TextColor="White" FontAttributes="Bold" VerticalOptions="Center" HorizontalOptions="Center" />
24+
</Grid>
25+
<syncfusion:SfListView x:Name="listView" Grid.Row="1" ScrollBarVisibility="Never"
26+
GroupHeaderSize="50"
27+
ItemSize="60"
28+
BackgroundColor="#FFE8E8EC"
29+
ItemsSource="{Binding ToDoList}"
30+
DragStartMode="OnHold,OnDragIndicator"
31+
SelectionMode="None">
32+
<syncfusion:SfListView.DataSource>
33+
<data:DataSource>
34+
<data:DataSource.GroupDescriptors>
35+
<data:GroupDescriptor PropertyName="CategoryName" />
36+
</data:DataSource.GroupDescriptors>
37+
</data:DataSource>
38+
</syncfusion:SfListView.DataSource>
39+
<syncfusion:SfListView.GroupHeaderTemplate>
40+
<DataTemplate>
41+
<Grid>
42+
<Label Text="{Binding Key}" FontSize="14" TextColor="#333333" FontAttributes="Bold" VerticalOptions="Center" HorizontalOptions="Start" Margin="15,0,0,0" />
43+
</Grid>
44+
</DataTemplate>
45+
</syncfusion:SfListView.GroupHeaderTemplate>
46+
<syncfusion:SfListView.ItemTemplate>
47+
<DataTemplate>
48+
<Grid BackgroundColor="White">
49+
<Grid.ColumnDefinitions>
50+
<ColumnDefinition Width="70" />
51+
<ColumnDefinition Width="*" />
52+
<ColumnDefinition Width="60" />
53+
</Grid.ColumnDefinitions>
54+
<Grid Padding="25,20,25,20" >
55+
<Grid.GestureRecognizers>
56+
<TapGestureRecognizer Command="{Binding Path=BindingContext.MarkDoneCommand, Source={x:Reference Name=listView}}" CommandParameter="{Binding .}"/>
57+
</Grid.GestureRecognizers>
58+
<Image Source="checked.png" HorizontalOptions="Center" VerticalOptions="Center" Aspect="AspectFill" IsVisible="{Binding IsDone}"/>
59+
<Image Source="unchecked.png" HorizontalOptions="Center" VerticalOptions="Center" Aspect="AspectFill"
60+
IsVisible="{Binding IsDone, Converter={StaticResource inverseBoolConverter}}"/>
61+
</Grid>
62+
<Label x:Name="textLabel" Text="{Binding Name}" Grid.Column="1" FontSize="15" TextColor="#333333" VerticalOptions="Center" HorizontalOptions="Start" Margin="5,0,0,0" />
63+
<BoxView Grid.Column="1" Margin="5,3,0,0" BackgroundColor="#333333" HeightRequest="1" WidthRequest="{Binding Source={x:Reference textLabel}, Path=Width}"
64+
VerticalOptions="Center" HorizontalOptions="Start" IsVisible="{Binding IsDone}" />
65+
<syncfusion:DragIndicatorView Grid.Column="2" ListView="{x:Reference listView}" HorizontalOptions="Center" VerticalOptions="Center">
66+
<Grid Padding="10, 20, 20, 20">
67+
<Image Source="dragindicator.png" VerticalOptions="Center" HorizontalOptions="Center" />
68+
</Grid>
69+
</syncfusion:DragIndicatorView>
70+
</Grid>
71+
</DataTemplate>
72+
</syncfusion:SfListView.ItemTemplate>
73+
</syncfusion:SfListView>
74+
</Grid>
75+
76+
</ContentPage>

ListViewMaui/MainPage.xaml.cs

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

ListViewMaui/MauiProgram.cs

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

ListViewMaui/Model/ToDoItem.cs

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
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 ListViewMaui
9+
{
10+
public class ToDoItem : INotifyPropertyChanged
11+
{
12+
#region Fields
13+
14+
private string name;
15+
private string categoryName;
16+
private bool isDone;
17+
18+
#endregion
19+
20+
#region Constructor
21+
22+
public ToDoItem()
23+
{
24+
25+
}
26+
27+
#endregion
28+
29+
#region Properties
30+
31+
public string Name
32+
{
33+
get { return name; }
34+
set
35+
{
36+
name = value;
37+
OnPropertyChanged("Name");
38+
}
39+
}
40+
41+
public string CategoryName
42+
{
43+
get { return categoryName; }
44+
set
45+
{
46+
categoryName = value;
47+
OnPropertyChanged("CategoryName");
48+
}
49+
}
50+
51+
public bool IsDone
52+
{
53+
get { return isDone; }
54+
set
55+
{
56+
if (isDone != value)
57+
{
58+
isDone = value;
59+
OnPropertyChanged("IsDone");
60+
}
61+
}
62+
}
63+
64+
#endregion
65+
66+
#region Interface Member
67+
68+
public event PropertyChangedEventHandler PropertyChanged;
69+
70+
public void OnPropertyChanged(string name)
71+
{
72+
if (this.PropertyChanged != null)
73+
this.PropertyChanged(this, new PropertyChangedEventArgs(name));
74+
}
75+
76+
#endregion
77+
}
78+
}

0 commit comments

Comments
 (0)