Barnamenevis.Net.RtlMessageBox.Wpf 1.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package Barnamenevis.Net.RtlMessageBox.Wpf --version 1.0.1
                    
NuGet\Install-Package Barnamenevis.Net.RtlMessageBox.Wpf -Version 1.0.1
                    
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="Barnamenevis.Net.RtlMessageBox.Wpf" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Barnamenevis.Net.RtlMessageBox.Wpf" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="Barnamenevis.Net.RtlMessageBox.Wpf" />
                    
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 Barnamenevis.Net.RtlMessageBox.Wpf --version 1.0.1
                    
#r "nuget: Barnamenevis.Net.RtlMessageBox.Wpf, 1.0.1"
                    
#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 Barnamenevis.Net.RtlMessageBox.Wpf@1.0.1
                    
#: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=Barnamenevis.Net.RtlMessageBox.Wpf&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=Barnamenevis.Net.RtlMessageBox.Wpf&version=1.0.1
                    
Install as a Cake Tool

Barnamenevis.Net.RtlMessageBox.Wpf

A pure WPF implementation of RTL-enabled MessageBox with Persian language support, custom theming, and automatic Persian button text translation. This library provides a drop-in replacement for WPF MessageBox with enhanced RTL layout support and Persian localization.

✨ Features

🌐 RTL Language Support

  • Automatic Persian Button Text: OK→تایید, Cancel→انصراف, Yes→بله, No→خیر
  • Right-to-Left Layout: Proper RTL text flow and UI alignment
  • Persian Font Integration: Automatic detection and use of installed Persian fonts
  • Unicode Support: Full support for Persian, and other RTL languages

🎨 Advanced UI Features

  • Themed MessageBox: Modern appearance that respects system themes
  • Custom Title Bars: Optional client-area title bars with Persian fonts
  • System Sound Integration: Appropriate sounds for Error, Warning, Information, and Question dialogs
  • Responsive Design: Auto-sizing based on content length and screen resolution
  • Focus Management: Proper keyboard navigation and focus indicators
  • Owner Window Support: Modal dialog behavior with proper parent window relationships

🔧 Technical Features

  • Drop-in Replacement: Compatible with standard WPF MessageBox API
  • No XAML: Entirely code-based for easy distribution
  • Theme Aware: Respects system colors and themes
  • Memory Efficient: Proper resource cleanup and disposal
  • Thread Safe: Can be called from UI thread

🎯 Supported Icon Types

  • MessageBoxImage.Error / Hand / Stop - Red X icon with error sound
  • MessageBoxImage.Warning / Exclamation - Yellow triangle with warning sound
  • MessageBoxImage.Information / Asterisk - Blue "i" icon (silent)
  • MessageBoxImage.Question - Blue "?" icon (silent)
  • MessageBoxImage.None - No icon

🔘 Button Mappings

  • MessageBoxButton.OK → "تایید"
  • MessageBoxButton.OKCancel → "تایید", "انصراف"
  • MessageBoxButton.YesNo → "بله", "خیر"
  • MessageBoxButton.YesNoCancel → "بله", "خیر", "انصراف"

⚙️ Requirements

  • .NET 6.0, 7.0, 8.0, or 9.0 (Windows)
  • WPF Application target framework
  • Windows 10/11 (for system icon loading)

🛠️ Integration

Add to Your WPF Project

  1. Add Project Reference:

    <ProjectReference Include="path\to\Barnamenevis.Net.RtlMessageBox.Wpf\Barnamenevis.Net.RtlMessageBox.Wpf.csproj" />
    
  2. Update your code:

    // Replace this:
    MessageBox.Show("Hello", "Title");
    
    // With this:
    RtlMessageBox.Show("سلام", "عنوان");
    
  3. Configure fonts (optional):

    // In App.xaml.cs or MainWindow constructor
    RtlMessageBox.PreferredFontName = "Vazirmatn FD";
    RtlMessageBox.PreferredFontPointSize = 11;
    

🚀 Quick Start Examples

Basic Usage

using Barnamenevis.Net.RtlMessageBox.Wpf;

// Simple information message
var result = RtlMessageBox.Show("عملیات با موفقیت انجام شد.", "موفقیت");

// Error message
var result = RtlMessageBox.Show(
    "خطا در اتصال به پایگاه داده رخ داد.",
    "خطا",
    MessageBoxButton.OK,
    MessageBoxImage.Error);

// Confirmation dialog
var result = RtlMessageBox.Show(
    "آیا مطمئن هستید که می‌خواهید این فایل را حذف کنید؟",
    "تأیید حذف",
    MessageBoxButton.YesNo,
    MessageBoxImage.Question);

if (result == MessageBoxResult.Yes)
{
    // Perform delete operation
    DeleteFile();
}

Advanced Configuration

// In App.xaml.cs
protected override void OnStartup(StartupEventArgs e)
{
    // Configure Persian fonts
    RtlMessageBox.PreferredFontName = "Vazirmatn FD";
    RtlMessageBox.PreferredFontPointSize = 12;
    RtlMessageBox.UseCustomTitleBar = true;
    RtlMessageBox.ApplyCustomFont = true;
    
    base.OnStartup(e);
}

📖 Best Practices

  1. Font Setup: Use Persian fonts like Vazirmatn for optimal typography
  2. Owner Windows: Always specify owner windows for modal behavior
  3. Icon Usage: Use appropriate icons for message types
  4. Text Length: Keep messages concise; the dialog will auto-size
  5. Default Buttons: Let the library handle default button selection for better UX

🔗 Integration with FontInstaller

This library works seamlessly with Barnamenevis.Net.Tools.FontInstaller:

// In App.xaml.cs
protected override void OnStartup(StartupEventArgs e)
{
    // Install fonts first
    var installedCount = FontInstaller.InstallApplicationFonts();
    if (installedCount > 0)
    {
        Console.WriteLine($"✅ نصب شد {installedCount} فونت جدید");
    }
    
    // Configure RtlMessageBox to use installed font
    RtlMessageBox.PreferredFontName = "Vazirmatn FD";
    RtlMessageBox.ApplyCustomFont = true;
    
    base.OnStartup(e);
}

🎨 Customization Options

Font Customization

// Set Persian font
RtlMessageBox.PreferredFontName = "Vazirmatn FD";
RtlMessageBox.PreferredFontPointSize = 11;

// Enable custom title bar
RtlMessageBox.UseCustomTitleBar = true;

// Apply font to all elements
RtlMessageBox.ApplyCustomFont = true;

Theme Integration

// The MessageBox automatically adapts to system theme
// Dark mode, light mode, and high contrast themes are supported
var result = RtlMessageBox.Show(
    "این پیغام با تم سیستم سازگار است.",
    "سازگاری تم",
    MessageBoxButton.OK,
    MessageBoxImage.Information);

🏗️ Technical Architecture

Component Structure

  • RtlMessageBox: Main static class with Show methods
  • RtlMessageBoxWindow: Custom WPF Window implementation
  • PersianButtonManager: Handles button text translation
  • FontManager: Manages font detection and application
  • SoundManager: Handles system sound integration

Memory Management

  • Automatic resource cleanup
  • Proper disposal of font resources
  • Efficient window lifecycle management
  • No memory leaks in repeated usage

📚 See Also

Product Compatible and additional computed target framework versions.
.NET net6.0-windows7.0 is compatible.  net7.0-windows was computed.  net7.0-windows7.0 is compatible.  net8.0-windows was computed.  net8.0-windows7.0 is compatible.  net9.0-windows was computed.  net9.0-windows7.0 is compatible.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net6.0-windows7.0

    • No dependencies.
  • net7.0-windows7.0

    • No dependencies.
  • net8.0-windows7.0

    • No dependencies.
  • net9.0-windows7.0

    • No dependencies.

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
1.0.2 179 10/3/2025
1.0.1 199 10/2/2025
1.0.0 260 10/1/2025

Version 1.0.1:
- Modern Windows Icons are used in dialogs instead of legacy ones.
Version 1.0.0 - Multi-targeting support:
- Pure WPF implementation with themed UI
- Compatible with .NET 6.0, 7.0, 8.0, and 9.0 (Windows)
- Automatic Persian button text translation
- Custom title bars with Persian fonts
- System sound integration
- Full RTL layout support
- Drop-in replacement for standard MessageBox