MauiPersianToolkit 2.0.9

Prefix Reserved
dotnet add package MauiPersianToolkit --version 2.0.9
                    
NuGet\Install-Package MauiPersianToolkit -Version 2.0.9
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MauiPersianToolkit" Version="2.0.9" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MauiPersianToolkit" Version="2.0.9" />
                    
Directory.Packages.props
<PackageReference Include="MauiPersianToolkit" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add MauiPersianToolkit --version 2.0.9
                    
#r "nuget: MauiPersianToolkit, 2.0.9"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package MauiPersianToolkit@2.0.9
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=MauiPersianToolkit&version=2.0.9
                    
Install as a Cake Addin
#tool nuget:?package=MauiPersianToolkit&version=2.0.9
                    
Install as a Cake Tool

Maui Persian Toolkit

NuGet License Build Tests .NET 8

MauiPersianToolkit is a comprehensive library for .NET MAUI that provides a variety of Persian language UI controls and components with full support for multiple calendar systems. This library is designed to help developers create modern, cross-platform applications with support for Persian language and right-to-left (RTL) layouts.

โœจ Key Features

๐Ÿ“… Advanced Calendar System

  • Multiple Calendar Support: Persian (Jalali), Gregorian, and Islamic (Hijri) calendars
  • Flexible DatePicker: Single, Multiple, and Range selection modes
  • Calendar Service Architecture: Strategy pattern for extensible calendar implementations
  • Full Calendar Validation: Automatic week alignment and day-of-week positioning
  • 20+ Unit Tests: Comprehensive test coverage for calendar functionality

๐ŸŽจ UI Controls

  • Persian DatePicker: Customizable date picker with multiple selection modes
  • TreeView: Supports None, Single, and Multiple selection modes with hierarchy support
  • TabView: Customizable tab control with multiple tabs and dynamic content
  • SlideButton: Interactive slideable button for confirmation actions
  • Picker: Single and Multiple selection pickers with enhanced UI
  • Entry & Editor: Enhanced text entry controls with Persian language and RTL support
  • Expander: Expandable and collapsible container for dynamic content
  • CheckBox, Button, Circle Image: Custom-styled UI components

๐Ÿ’ฌ Dialog System

  • Alert Dialog: Simple message dialog
  • Confirm Dialog: Dialog with confirmation options
  • Prompt Dialog: Dialog to capture user input
  • Custom Dialog: Fully customizable dialog with any content

๐Ÿ› ๏ธ Developer Tools

  • Converters: PersianDateConverter, PersianDateTimeConverter, and more
  • Extensions: Calendar extensions for easy date manipulation
  • Custom Fonts: Built-in support for IranianSans and FontAwesome fonts
  • RTL Support: Full right-to-left layout support for all controls

๐Ÿ“‹ Project Statistics

  • Version: 2.0.7
  • Target Framework: .NET 8.0+
  • Platforms: Windows, iOS, Android
  • License: MIT
  • Tests: 20+ unit tests (Calendar Service + Week Layout)
  • Code Quality: CI/CD with automated testing on every PR

๐Ÿš€ Installation

You can install the MauiPersianToolkit package via NuGet Package Manager or .NET CLI:

NuGet Package Manager

Install-Package MauiPersianToolkit

.NET CLI

dotnet add package MauiPersianToolkit

๐ŸŽฏ Getting Started

1. Startup Configuration

Add the Persian Toolkit to your MauiApp in MauiProgram.cs:

public static class MauiProgram
{
    public static MauiApp CreateMauiApp()
    {
        var builder = MauiApp.CreateBuilder();
        builder
            .UseMauiApp<App>()
            .ConfigureFonts(fonts =>
            {
                fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
                fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
                fonts.AddFont("IranianSans.ttf", "IranianSans");
            })
            .UseMauiCommunityToolkit()
            .UsePersianUIControls();  // Add this line
        
        return builder.Build();
    }
}

2. Basic XAML Usage

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:persian="clr-namespace:MauiPersianToolkit.Controls;assembly=MauiPersianToolkit"
             x:Class="YourApp.MainPage"
             Title="Persian Toolkit Demo">

    <ScrollView>
        <StackLayout Padding="20" Spacing="15">
            
            
            <Label Text="Persian DatePicker (Single)" FontSize="16" FontAttributes="Bold"/>
            <persian:DatePicker 
                PlaceHolder="Select Date" 
                SelectedPersianDate="{Binding SelectedDate}"
                CalendarType="Persian"
                DisplayFormat="yyyy/MM/dd" />
            
            
            <Label Text="Gregorian DatePicker" FontSize="16" FontAttributes="Bold"/>
            <persian:DatePicker 
                PlaceHolder="Select Date" 
                SelectedPersianDate="{Binding SelectedGregorianDate}"
                CalendarType="Gregorian"
                DisplayFormat="yyyy/MM/dd" />
            
            
            <Label Text="Islamic DatePicker" FontSize="16" FontAttributes="Bold"/>
            <persian:DatePicker 
                PlaceHolder="Select Date" 
                SelectedPersianDate="{Binding SelectedHijriDate}"
                CalendarType="Hijri"
                DisplayFormat="yyyy/MM/dd" />

            
            <Label Text="Entry Field" FontSize="16" FontAttributes="Bold"/>
            <persian:EntryView 
                PlaceHolder="Enter your name" 
                Text="{Binding UserName}" />

            
            <Label Text="Expandable Section" FontSize="16" FontAttributes="Bold"/>
            <persian:Expander IsExpanded="False" Header="Click to expand">
                <Label Text="This content is hidden until expanded" Padding="10"/>
            </persian:Expander>

        </StackLayout>
    </ScrollView>
</ContentPage>

3. Calendar System Usage

Using Calendar Services Directly
using MauiPersianToolkit.Services.Calendar;
using MauiPersianToolkit.Enums;

// Get calendar service
var persianService = CalendarServiceFactory.GetService(CalendarType.Persian);
var gregorianService = CalendarServiceFactory.GetService(CalendarType.Gregorian);
var hijriService = CalendarServiceFactory.GetService(CalendarType.Hijri);

// Convert dates
var today = DateTime.Now;
string persianDate = persianService.ToCalendarDate(today);      // "1403/05/25"
string gregorianDate = gregorianService.ToCalendarDate(today);  // "2024/08/16"
string hijriDate = hijriService.ToCalendarDate(today);          // "1446/02/21"

// Parse dates back
var parsed = persianService.ToGregorianDate("1403/05/25");

// Get calendar information
int year = persianService.GetYear(today);
int month = persianService.GetMonth(today);
string monthName = persianService.GetMonthName(month);
bool isLeap = persianService.IsLeapYear(year);
DayOfWeek holiday = persianService.GetLastDayOfWeek();  // Friday for Persian
Using Extension Methods (Backward Compatible)
using MauiPersianToolkit;

DateTime today = DateTime.Now;

// Convert to Persian (default)
string persianDate = today.ToPersianDate();  // "1403/05/25"

// Convert to other calendars
string gregorianDate = today.ToCalendarDate(CalendarType.Gregorian);
string hijriDate = today.ToCalendarDate(CalendarType.Hijri);

// Parse back
var parsed = "1403/05/25".ToDateTime();
var gregorianParsed = "2024/08/16".ToDateTime(CalendarType.Gregorian);

4. Dialog Usage

using MauiPersianToolkit.Services.Dialog;
using MauiPersianToolkit.Models;

public partial class MainPage : ContentPage
{
    private readonly IDialogService _dialogService;
    
    public MainPage(IDialogService dialogService)
    {
        InitializeComponent();
        _dialogService = dialogService;
    }

    // Alert Dialog
    private async void ShowAlert()
    {
        await _dialogService.Alert("This is an alert message");
    }

    // Confirm Dialog
    private async void ShowConfirm()
    {
        var config = new ConfirmConfig
        {
            Title = "Confirm Action",
            Message = "Are you sure?",
            AcceptText = "Yes",
            CancelText = "No",
            OnAction = (result) =>
            {
                if (result)
                    Debug.WriteLine("User confirmed");
                else
                    Debug.WriteLine("User cancelled");
            }
        };
        
        await _dialogService.Confirm(config);
    }

    // Prompt Dialog
    private async void ShowPrompt()
    {
        var config = new PromptConfig
        {
            Title = "Enter Name",
            Message = "Please enter your name:",
            Placeholder = "Name",
            AcceptText = "OK",
            CancelText = "Cancel",
            OnAction = (result) =>
            {
                if (result.IsOk)
                    Debug.WriteLine($"User entered: {result.Input}");
            }
        };
        
        await _dialogService.Prompt(config);
    }

    // Custom Dialog
    private async void ShowCustomDialog()
    {
        var customContent = new StackLayout
        {
            Children =
            {
                new EntryView { PlaceHolder = "Name" },
                new EntryView { PlaceHolder = "Email" },
                new persian:DatePicker { PlaceHolder = "Birth Date" }
            }
        };

        var config = new CustomDialogConfig
        {
            Title = "Register",
            Message = "Enter your information",
            Content = customContent,
            AcceptText = "Register",
            CancelText = "Cancel",
            OnAction = (result) =>
            {
                Debug.WriteLine($"Dialog result: {result}");
            }
        };
        
        await _dialogService.CustomDialog(config);
    }
}

๐Ÿ“š Examples and Documentation

Calendar Service Examples

See MauiPersianToolkit/Examples/CalendarServiceExamples.cs for:

  • Extension methods usage
  • Calendar service factory usage
  • Calendar conversions
  • DatePicker control usage
  • Custom calendar registration

Calendar Tests

The project includes comprehensive unit tests:

CalendarServiceTests - 7 tests covering:

  • Date conversion roundtrip
  • Month boundaries
  • Holiday detection
  • Month names
  • Leap year validation
  • DatePickerViewModel integration
  • Date formatting

CalendarWeekLayoutTests - 13+ tests covering:

  • Consecutive days alignment
  • Week structure (7 columns per week)
  • Persian calendar day positioning
  • Gregorian calendar day positioning
  • Empty cells before first day
  • End of month positioning
  • Multiple month validation
  • Holiday day placement
  • Specific date column placement

Run tests:

dotnet test ./MauiPersianToolkit.Test/MauiPersianToolkit.Test.csproj

๐Ÿ”ง Customization

All controls are designed to be easily customizable:

Custom Calendar Type

Implement ICalendarService for custom calendar support:

public class MyCustomCalendarService : ICalendarService
{
    // Implement interface methods
    public string ToCalendarDate(DateTime gregorianDate) { /* ... */ }
    public DateTime ToGregorianDate(string calendarDate) { /* ... */ }
    // ... other methods
}

// Register with factory
CalendarServiceFactory.RegisterService(
    CalendarType.Custom, 
    new MyCustomCalendarService()
);

Style Customization

Customize colors, fonts, and behaviors:

<persian:DatePicker
    PlaceHolder="Select Date"
    SelectDayColor="Blue"
    CanSelectHolidays="False"
    DisplayFormat="yyyy/MM/dd" />

๐Ÿงช Testing

The project includes a comprehensive test suite:

MauiPersianToolkit.Test/
โ”œโ”€โ”€ CalendarServiceTests.cs (7 tests)
โ”œโ”€โ”€ CalendarWeekLayoutTests.cs (13+ tests)
โ””โ”€โ”€ CalendarWeekLayoutTests.README.md (documentation)

GitHub Actions CI/CD

Automated testing on every commit:

  • โœ… Build validation
  • โœ… Unit tests execution
  • โœ… Calendar-specific tests
  • โœ… Code coverage reports

See .github/workflows/ for CI/CD configuration.

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿค Contributing

We welcome contributions! Follow these steps:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/YourFeature)
  3. Commit your changes (git commit -m 'Add YourFeature')
  4. Push to the branch (git push origin feature/YourFeature)
  5. Open a Pull Request

Contribution Guidelines

  • Follow existing code style and conventions
  • Add unit tests for new features
  • Update documentation as needed
  • Ensure all tests pass locally
  • Provide clear PR description

๐Ÿ™ Acknowledgments

  • .NET MAUI Community for excellent framework and tools
  • CommunityToolkit.Maui for reusable components
  • All contributors and users for feedback and suggestions

๐Ÿ“ž Support

๐Ÿ“Š Project Status

Component Status Coverage
Core Library โœ… Stable Mature
Calendar System โœ… Stable 3 calendars
UI Controls โœ… Stable 10+ controls
Dialog System โœ… Stable 4 types
Unit Tests โœ… Complete 20+ tests
Documentation โœ… Complete Full

Happy Coding! ๐Ÿš€

Start building beautiful Persian-enabled applications with MauiPersianToolkit today!

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-android34.0 is compatible.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-ios18.0 is compatible.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net8.0-windows10.0.19041 is compatible.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.9 109 5/7/2026
2.0.8 155 1/2/2026
2.0.7 124 1/2/2026
2.0.6 362 12/11/2024
2.0.5 221 10/24/2024
2.0.4 217 9/27/2024
2.0.3 278 8/23/2024