Skip to content

Commit 0afab8e

Browse files
Merge pull request #1 from SyncfusionExamples/Attach_the_Sample
Attach the Customize Legend Layout .NET MAUI KB sample
2 parents c1286f5 + d10d8dc commit 0afab8e

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

+9275
-2
lines changed
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.35506.116
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CustomizeLegendLayout", "CustomizeLegendLayout\CustomizeLegendLayout.csproj", "{326FCBB2-097F-489A-997A-5B165DC09A81}"
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+
{326FCBB2-097F-489A-997A-5B165DC09A81}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{326FCBB2-097F-489A-997A-5B165DC09A81}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{326FCBB2-097F-489A-997A-5B165DC09A81}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{326FCBB2-097F-489A-997A-5B165DC09A81}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
EndGlobal
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:CustomizeLegendLayout"
5+
x:Class="CustomizeLegendLayout.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>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
namespace CustomizeLegendLayout
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+
}
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="CustomizeLegendLayout.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:CustomizeLegendLayout"
7+
Shell.FlyoutBehavior="Flyout"
8+
Title="CustomizeLegendLayout">
9+
10+
<ShellContent
11+
Title="Home"
12+
ContentTemplate="{DataTemplate local:MainPage}"
13+
Route="MainPage" />
14+
15+
</Shell>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
namespace CustomizeLegendLayout
2+
{
3+
public partial class AppShell : Shell
4+
{
5+
public AppShell()
6+
{
7+
InitializeComponent();
8+
}
9+
}
10+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
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>CustomizeLegendLayout</RootNamespace>
18+
<UseMaui>true</UseMaui>
19+
<SingleProject>true</SingleProject>
20+
<ImplicitUsings>enable</ImplicitUsings>
21+
<Nullable>enable</Nullable>
22+
23+
<!-- Display name -->
24+
<ApplicationTitle>CustomizeLegendLayout</ApplicationTitle>
25+
26+
<!-- App Identifier -->
27+
<ApplicationId>com.companyname.customizelegendlayout</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="CommunityToolkit.Maui" Version="*" />
64+
<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" />
65+
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="*" />
66+
<PackageReference Include="Syncfusion.Maui.Charts" Version="*" />
67+
</ItemGroup>
68+
69+
</Project>
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
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:chart="clr-namespace:Syncfusion.Maui.Charts;assembly=Syncfusion.Maui.Charts"
5+
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
6+
xmlns:local="clr-namespace:CustomizeLegendLayout"
7+
x:Class="CustomizeLegendLayout.MainPage">
8+
9+
<ContentPage.BindingContext>
10+
<local:ViewModel/>
11+
</ContentPage.BindingContext>
12+
13+
<chart:SfPyramidChart ItemsSource="{Binding Data}"
14+
XBindingPath="Stage"
15+
YBindingPath="Value"
16+
GapRatio="0.1"
17+
PaletteBrushes="{Binding CustomBrushes}">
18+
19+
<chart:SfPyramidChart.Title>
20+
<Label Text="Social Media Sharing" FontSize="17" FontAttributes="Bold" HorizontalTextAlignment="Center"/>
21+
</chart:SfPyramidChart.Title>
22+
23+
<chart:SfPyramidChart.Legend>
24+
<local:LegendExt Placement="Right">
25+
<local:LegendExt.ItemsLayout>
26+
<toolkit:UniformItemsLayout MaxRows="12" MaxColumns="4" WidthRequest="600" FlowDirection="LeftToRight"/>
27+
</local:LegendExt.ItemsLayout>
28+
<local:LegendExt.ItemTemplate>
29+
<DataTemplate>
30+
<Grid ColumnDefinitions="20, *, Auto" VerticalOptions="Center">
31+
<BoxView Grid.Column="0"
32+
HeightRequest="12"
33+
WidthRequest="12"
34+
Margin="0,0,0,15"
35+
Background="{Binding IconBrush}"
36+
VerticalOptions="Center"/>
37+
38+
<Label Grid.Column="1"
39+
Text="{Binding Item.Stage}"
40+
Margin="0,0,5,15"
41+
Padding="0,0,0,3"
42+
HorizontalTextAlignment="Start"
43+
FontSize="Caption"
44+
VerticalOptions="Center"/>
45+
46+
<Label Grid.Column="2"
47+
Text="{Binding Item.Value}"
48+
FontSize="Caption"
49+
HorizontalTextAlignment="End"
50+
Margin="0,0,50,15"
51+
Padding="0,0,0,3"
52+
VerticalOptions="Center"/>
53+
</Grid>
54+
</DataTemplate>
55+
</local:LegendExt.ItemTemplate>
56+
</local:LegendExt>
57+
</chart:SfPyramidChart.Legend>
58+
59+
</chart:SfPyramidChart>
60+
61+
</ContentPage>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using CommunityToolkit.Maui.Layouts;
2+
using Microsoft.Maui.Layouts;
3+
using Syncfusion.Maui.Charts;
4+
using Syncfusion.Maui.Core;
5+
using System.Globalization;
6+
7+
namespace CustomizeLegendLayout
8+
{
9+
public partial class MainPage : ContentPage
10+
{
11+
public MainPage()
12+
{
13+
InitializeComponent();
14+
}
15+
}
16+
17+
public class LegendExt : ChartLegend
18+
{
19+
protected override double GetMaximumSizeCoefficient()
20+
{
21+
return 0.7;
22+
}
23+
}
24+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+

2+
using CommunityToolkit.Maui;
3+
using Microsoft.Extensions.Logging;
4+
using Syncfusion.Maui.Core.Hosting;
5+
6+
namespace CustomizeLegendLayout
7+
{
8+
public static class MauiProgram
9+
{
10+
public static MauiApp CreateMauiApp()
11+
{
12+
var builder = MauiApp.CreateBuilder();
13+
builder.UseMauiCommunityToolkit();
14+
builder
15+
.UseMauiApp<App>()
16+
.ConfigureSyncfusionCore()
17+
.ConfigureFonts(fonts =>
18+
{
19+
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
20+
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
21+
});
22+
23+
#if DEBUG
24+
builder.Logging.AddDebug();
25+
#endif
26+
27+
return builder.Build();
28+
}
29+
}
30+
}
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 CustomizeLegendLayout
8+
{
9+
internal class Model
10+
{
11+
public string? Stage { get; set; }
12+
public double Value { get; set; }
13+
}
14+
}

0 commit comments

Comments
 (0)