Skip to content

Commit f457c66

Browse files
Merge pull request #1 from SyncfusionExamples/Sample
Added the sample for the KB
2 parents 88d3770 + 11fb9ba commit f457c66

Some content is hidden

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

42 files changed

+9222
-2
lines changed

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

MauiDrawer/App.xaml.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
namespace MauiDrawer
2+
{
3+
public partial class App : Application
4+
{
5+
public App()
6+
{
7+
InitializeComponent();
8+
}
9+
10+
protected override Window CreateWindow(IActivationState? activationState)
11+
{
12+
return new Window(new AppShell());
13+
}
14+
}
15+
}

MauiDrawer/AppShell.xaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<Shell
3+
x:Class="MauiDrawer.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:MauiDrawer"
7+
Shell.FlyoutBehavior="Flyout"
8+
Title="MauiDrawer">
9+
10+
<ShellContent
11+
Title="Home"
12+
ContentTemplate="{DataTemplate local:MainPage}"
13+
Route="MainPage" />
14+
15+
</Shell>

MauiDrawer/AppShell.xaml.cs

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

MauiDrawer/MainPage.xaml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
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+
x:Class="MauiDrawer.MainPage"
5+
xmlns:local="clr-namespace:MauiDrawer"
6+
xmlns:navigationdrawer="clr-namespace:Syncfusion.Maui.NavigationDrawer;assembly=Syncfusion.Maui.NavigationDrawer">
7+
8+
<ContentPage.BindingContext>
9+
<local:MainPageViewModel/>
10+
</ContentPage.BindingContext>
11+
12+
<navigationdrawer:SfNavigationDrawer x:Name="navigationDrawer" IsOpen="{Binding IsDrawerOpen,Mode=TwoWay}">
13+
<navigationdrawer:SfNavigationDrawer.DrawerSettings>
14+
<navigationdrawer:DrawerSettings DrawerWidth="230" DrawerHeaderHeight="150" >
15+
<navigationdrawer:DrawerSettings.DrawerHeaderView>
16+
<Grid BackgroundColor="#6750A4" RowDefinitions="120,40">
17+
<Image Source="user.png"
18+
HeightRequest="110"
19+
Margin="0,10,0,0"
20+
BackgroundColor="#6750A4"
21+
VerticalOptions="Center"
22+
HorizontalOptions="Center"/>
23+
<Label Text="James Pollock"
24+
Grid.Row="1"
25+
HorizontalTextAlignment="Center"
26+
HorizontalOptions="Center"
27+
FontSize="20"
28+
TextColor="White"/>
29+
</Grid>
30+
</navigationdrawer:DrawerSettings.DrawerHeaderView>
31+
<navigationdrawer:DrawerSettings.DrawerContentView>
32+
<VerticalStackLayout x:Name="drawerContentView" Spacing="10" HorizontalOptions="Center" Margin="20">
33+
<ListView x:Name="listView"
34+
ItemSelected="listView_ItemSelected">
35+
<ListView.ItemTemplate>
36+
<DataTemplate>
37+
<ViewCell>
38+
<VerticalStackLayout HeightRequest="40">
39+
<Label Margin="10,7,0,0"
40+
Text="{Binding}"
41+
FontSize="16"
42+
TextColor="Black"/>
43+
</VerticalStackLayout>
44+
</ViewCell>
45+
</DataTemplate>
46+
</ListView.ItemTemplate>
47+
</ListView>
48+
</VerticalStackLayout>
49+
</navigationdrawer:DrawerSettings.DrawerContentView>
50+
</navigationdrawer:DrawerSettings>
51+
</navigationdrawer:SfNavigationDrawer.DrawerSettings>
52+
<navigationdrawer:SfNavigationDrawer.ContentView>
53+
<Grid x:Name="mainContentView"
54+
BackgroundColor="White" RowDefinitions="Auto,*">
55+
<HorizontalStackLayout BackgroundColor="#6750A4" Spacing="10" Padding="5,0,0,0">
56+
<ImageButton x:Name="hamburgerButton"
57+
HeightRequest="50"
58+
WidthRequest="50"
59+
HorizontalOptions="Start"
60+
Source="hamburgericon.png"
61+
BackgroundColor="#6750A4"
62+
Command="{Binding ToggleDrawerCommand}"/>
63+
<Label x:Name="headerLabel"
64+
HeightRequest="50"
65+
HorizontalTextAlignment="Center"
66+
VerticalTextAlignment="Center"
67+
Text="Home" FontSize="16"
68+
TextColor="White"
69+
BackgroundColor="#6750A4"/>
70+
</HorizontalStackLayout>
71+
<Label Grid.Row="1"
72+
x:Name="contentLabel"
73+
VerticalOptions="Center"
74+
HorizontalOptions="Center"
75+
Text="Home"
76+
FontSize="14"
77+
TextColor="Black"/>
78+
</Grid>
79+
</navigationdrawer:SfNavigationDrawer.ContentView>
80+
</navigationdrawer:SfNavigationDrawer>
81+
82+
</ContentPage>

MauiDrawer/MainPage.xaml.cs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
namespace MauiDrawer
2+
{
3+
public partial class MainPage : ContentPage
4+
{
5+
private List<string> list;
6+
public MainPage()
7+
{
8+
InitializeComponent();
9+
10+
list = new List<string>();
11+
list.Add("Home");
12+
list.Add("Profile");
13+
list.Add("Inbox");
14+
list.Add("Out box");
15+
list.Add("Sent");
16+
list.Add("Draft");
17+
listView.ItemsSource = list;
18+
}
19+
private void listView_ItemSelected(object sender, SelectedItemChangedEventArgs e)
20+
{
21+
if (e.SelectedItem.ToString() == "Home")
22+
contentLabel.Text = "Home";
23+
else if (e.SelectedItem.ToString() == "Profile")
24+
contentLabel.Text = "Profile";
25+
else if (e.SelectedItem.ToString() == "Inbox")
26+
contentLabel.Text = "Inbox";
27+
else if (e.SelectedItem.ToString() == "Out box")
28+
contentLabel.Text = "Out box";
29+
else if (e.SelectedItem.ToString() == "Sent")
30+
contentLabel.Text = "Sent";
31+
else if (e.SelectedItem.ToString() == "Draft")
32+
contentLabel.Text = "The folder is empty";
33+
navigationDrawer.ToggleDrawer();
34+
}
35+
}
36+
37+
}

MauiDrawer/MainPageViewModel.cs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
using System.ComponentModel;
2+
using System.Windows.Input;
3+
4+
namespace MauiDrawer
5+
{
6+
public class MainPageViewModel : INotifyPropertyChanged
7+
{
8+
public event PropertyChangedEventHandler? PropertyChanged;
9+
public void OnPropertyChanged(string propertyName)
10+
{
11+
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
12+
}
13+
private bool _isDrawerOpen;
14+
public bool IsDrawerOpen
15+
{
16+
get => _isDrawerOpen;
17+
set
18+
{
19+
_isDrawerOpen = value;
20+
OnPropertyChanged(nameof(IsDrawerOpen));
21+
}
22+
}
23+
24+
public ICommand ToggleDrawerCommand { get; }
25+
26+
public MainPageViewModel()
27+
{
28+
ToggleDrawerCommand = new Command(ToggleDrawer);
29+
}
30+
31+
private void ToggleDrawer()
32+
{
33+
IsDrawerOpen = !IsDrawerOpen;
34+
}
35+
36+
}
37+
}

MauiDrawer/MauiDrawer.csproj

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFrameworks>net9.0-android;net9.0-ios;net9.0-maccatalyst</TargetFrameworks>
5+
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net9.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);net9.0-tizen</TargetFrameworks> -->
8+
9+
<!-- Note for MacCatalyst:
10+
The default runtime is maccatalyst-x64, except in Release config, in which case the default is maccatalyst-x64;maccatalyst-arm64.
11+
When specifying both architectures, use the plural <RuntimeIdentifiers> instead of the singular <RuntimeIdentifier>.
12+
The Mac App Store will NOT accept apps with ONLY maccatalyst-arm64 indicated;
13+
either BOTH runtimes must be indicated or ONLY macatalyst-x64. -->
14+
<!-- For example: <RuntimeIdentifiers>maccatalyst-x64;maccatalyst-arm64</RuntimeIdentifiers> -->
15+
16+
<OutputType>Exe</OutputType>
17+
<RootNamespace>MauiDrawer</RootNamespace>
18+
<UseMaui>true</UseMaui>
19+
<SingleProject>true</SingleProject>
20+
<ImplicitUsings>enable</ImplicitUsings>
21+
<Nullable>enable</Nullable>
22+
23+
<!-- Display name -->
24+
<ApplicationTitle>MauiDrawer</ApplicationTitle>
25+
26+
<!-- App Identifier -->
27+
<ApplicationId>com.companyname.mauidrawer</ApplicationId>
28+
29+
<!-- Versions -->
30+
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
31+
<ApplicationVersion>1</ApplicationVersion>
32+
33+
<!-- To develop, package, and publish an app to the Microsoft Store, see: https://aka.ms/MauiTemplateUnpackaged -->
34+
<WindowsPackageType>None</WindowsPackageType>
35+
36+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">15.0</SupportedOSPlatformVersion>
37+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">15.0</SupportedOSPlatformVersion>
38+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
39+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
40+
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
41+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion>
42+
</PropertyGroup>
43+
44+
<ItemGroup>
45+
<!-- App Icon -->
46+
<MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#512BD4" />
47+
48+
<!-- Splash Screen -->
49+
<MauiSplashScreen Include="Resources\Splash\splash.svg" Color="#512BD4" BaseSize="128,128" />
50+
51+
<!-- Images -->
52+
<MauiImage Include="Resources\Images\*" />
53+
<MauiImage Update="Resources\Images\dotnet_bot.png" Resize="True" BaseSize="300,185" />
54+
55+
<!-- Custom Fonts -->
56+
<MauiFont Include="Resources\Fonts\*" />
57+
58+
<!-- Raw Assets (also remove the "Resources\Raw" prefix) -->
59+
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
60+
</ItemGroup>
61+
62+
<ItemGroup>
63+
<PackageReference Include="Microsoft.Maui.Controls" Version="9.0.30" />
64+
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="9.0.0" />
65+
<PackageReference Include="Syncfusion.Maui.NavigationDrawer" Version="*" />
66+
</ItemGroup>
67+
68+
</Project>

MauiDrawer/MauiDrawer.sln

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.12.35514.174
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MauiDrawer", "MauiDrawer.csproj", "{A30406D2-8F48-42F9-96A0-A0CB4B4F94D7}"
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+
{A30406D2-8F48-42F9-96A0-A0CB4B4F94D7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{A30406D2-8F48-42F9-96A0-A0CB4B4F94D7}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{A30406D2-8F48-42F9-96A0-A0CB4B4F94D7}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{A30406D2-8F48-42F9-96A0-A0CB4B4F94D7}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
EndGlobal

MauiDrawer/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+
namespace MauiDrawer
5+
{
6+
public static class MauiProgram
7+
{
8+
public static MauiApp CreateMauiApp()
9+
{
10+
var builder = MauiApp.CreateBuilder();
11+
builder
12+
.UseMauiApp<App>()
13+
.ConfigureSyncfusionCore()
14+
.ConfigureFonts(fonts =>
15+
{
16+
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
17+
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
18+
});
19+
20+
#if DEBUG
21+
builder.Logging.AddDebug();
22+
#endif
23+
24+
return builder.Build();
25+
}
26+
}
27+
}

0 commit comments

Comments
 (0)