### Install Syncfusion MAUI Toolkit via NuGet CLI
Source: https://github.com/syncfusion/maui-toolkit/blob/main/README.md
Installs the Syncfusion MAUI Toolkit package using the .NET CLI. This is the recommended way to add the library to your project.
```bash
dotnet add package Syncfusion.Maui.Toolkit
```
--------------------------------
### Navigate and Build Toolkit (Shell)
Source: https://github.com/syncfusion/maui-toolkit/blob/main/DEVELOPMENT.md
Commands to navigate to the repository root and build the Syncfusion MAUI Toolkit solution using the .NET CLI. Requires .NET SDK and the repository cloned locally.
```shell
cd \repos\maui-toolkit
```
```shell
dotnet tool restore
dotnet build ./Syncfusion.Maui.Toolkit.sln
```
--------------------------------
### Install Syncfusion MAUI Toolkit in .csproj
Source: https://github.com/syncfusion/maui-toolkit/blob/main/README.md
Adds the Syncfusion MAUI Toolkit as a project reference in the .csproj file. This method is useful for managing dependencies directly within the project configuration.
```xml
```
--------------------------------
### MAUI Cartesian Chart XAML Setup
Source: https://github.com/syncfusion/maui-toolkit/blob/main/README.md
This XAML code defines a Syncfusion Cartesian Chart in a MAUI application. It includes setting up axes, a legend, a title, and a ColumnSeries, binding to a ViewModel for data visualization. This is intended for the MainPage.xaml file.
```xml
```
--------------------------------
### Configure Syncfusion MAUI Toolkit in MauiProgram.cs
Source: https://github.com/syncfusion/maui-toolkit/blob/main/README.md
Initializes the Syncfusion MAUI Toolkit by calling the ConfigureSyncfusionToolkit() extension method in the MauiProgram.cs file. This enables all toolkit features for your .NET MAUI application.
```csharp
using Syncfusion.Maui.Toolkit.Hosting;
public static class MauiProgram
{
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp()
// Initialize the Syncfusion .NET MAUI Toolkit by adding the below line of code
.ConfigureSyncfusionToolkit()
// After initializing the Syncfusion .NET MAUI Toolkit, optionally add additional fonts
.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
});
// Continue initializing your .NET MAUI App here
return builder.Build();
}
}
```
--------------------------------
### MAUI ViewModel with Sample Data
Source: https://github.com/syncfusion/maui-toolkit/blob/main/README.md
This C# class 'ViewModel' provides sample data for the MAUI chart. It initializes a List of 'Person' objects, making it ready for data binding in the MAUI UI. This is crucial for populating the chart with data.
```csharp
///
/// ViewModel class that provides a list of Person objects for data binding.
///
public class ViewModel
{
///
/// Gets or sets the list of Person objects.
///
public List Data { get; set; }
///
/// Initializes a new instance of the ViewModel class with sample data.
///
public ViewModel()
{
// Initialize the Data property with a list of Person objects
Data = new List()
{
new Person { Name = "David", Height = 170 },
new Person { Name = "Michael", Height = 96 },
new Person { Name = "Steve", Height = 65 },
new Person { Name = "Joel", Height = 182 },
new Person { Name = "Bob", Height = 134 }
};
}
}
```
--------------------------------
### Add Syncfusion MAUI Toolkit XAML Namespace
Source: https://github.com/syncfusion/maui-toolkit/blob/main/README.md
Declares the Syncfusion MAUI Toolkit namespace in XAML for using toolkit components. This allows you to reference the toolkit's elements directly in your XAML markup.
```xml
xmlns:toolkit="http://schemas.syncfusion.com/maui/toolkit"
```
--------------------------------
### MAUI Person Data Model
Source: https://github.com/syncfusion/maui-toolkit/blob/main/README.md
Defines a simple C# class 'Person' to represent data points for the MAUI chart. It includes properties for 'Name' (string) and 'Height' (double). This class serves as the data structure for chart entries.
```csharp
///
/// Represents a person with a name and height.
///
public class Person
{
///
/// Gets or sets the name of the person.
///
public string Name { get; set; }
///
/// Gets or sets the height of the person.
///
public double Height { get; set; }
}
```
=== COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.