CastelloBranco.AvaloniaMessageBox 1.0.1

dotnet add package CastelloBranco.AvaloniaMessageBox --version 1.0.1
                    
NuGet\Install-Package CastelloBranco.AvaloniaMessageBox -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="CastelloBranco.AvaloniaMessageBox" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CastelloBranco.AvaloniaMessageBox" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="CastelloBranco.AvaloniaMessageBox" />
                    
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 CastelloBranco.AvaloniaMessageBox --version 1.0.1
                    
#r "nuget: CastelloBranco.AvaloniaMessageBox, 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 CastelloBranco.AvaloniaMessageBox@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=CastelloBranco.AvaloniaMessageBox&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=CastelloBranco.AvaloniaMessageBox&version=1.0.1
                    
Install as a Cake Tool

AvaloniaMessageBox

A flexible and modern modal message box implementation for Avalonia UI 11.2+.

Supports:

  • Classic Desktop applications (IClassicDesktopStyleApplicationLifetime)
  • Single view apps (ISingleViewApplicationLifetime)
  • Early fallback before MainWindow or MainView is ready
  • DPI-aware sizing and theme-aware font and styling
  • Optional icons and multi-line messages
  • Modal behavior even in SingleView via panel overlay

✨ Features

  • Compatible with .NET 9 and Avalonia 11.2+
  • Fully theme-aware (fonts, colors, shadows)
  • Automatically localizes button text (Yes, No, OK, Cancel) using CultureInfo.CurrentUICulture
  • Supports:
    • OK
    • OK / Cancel
    • Yes / No
  • Built-in modern emoji-based icons:
    • ℹ️ Info
    • ⚠️ Warning
    • ❌ Error
    • ✅ Success
    • ❓ Question
    • 🛑✋ Stop (hand over stop sign with overlay)
  • Works even before MainWindow or MainView is set

🌍 Localization Support

Button labels (OK, Cancel, Yes, No) are automatically translated based on the current UI culture (CultureInfo.CurrentUICulture).
Includes built-in translations for over 68 languages, including:

  • pt-BR → "Sim", "Não", "OK", "Cancelar"
  • es → "Sí", "No", "OK", "Cancelar"
  • fr → "Oui", "Non", "OK", "Annuler"
  • de → "Ja", "Nein", "OK", "Abbrechen"
  • ja → "はい", "いいえ", "OK", "キャンセル"
  • ...and many others

No configuration needed — just set the culture in your app startup code:

CultureInfo.DefaultThreadCurrentUICulture = CultureInfo.GetCultureInfo("pt-BR");

🚀 Usage

await AvaloniaWindowedMessageBox.ShowAsync(
    parent: this, // Can be a Window or UserControl
    title: "Attention",
    message: "Are you sure you want to continue?",
    buttons: AvaloniaWindowedMessageBox.MessageBoxButtons.YesNo,
    icon: AvaloniaWindowedMessageBox.MessageBoxIcon.Question);

You can call it even before setting MainWindow in your App.cs:

await AvaloniaWindowedMessageBox.ShowAsync(null, "Startup Error", "The configuration is invalid.");

🧪 Example with Stop Icon

await AvaloniaWindowedMessageBox.ShowAsync(
    this,
    "Restricted",
    "Access denied.",
    AvaloniaWindowedMessageBox.MessageBoxButtons.Ok,
    AvaloniaWindowedMessageBox.MessageBoxIcon.Stop);

This renders a composite emoji with 🛑 background and ✋ overlaid at center.

🧩 Installation

Simply copy AvaloniaWindowedMessageBox.cs into your project.
No dependencies or NuGet packages required.

📄 License

MIT License
(c) 2024 Castello Branco Tecnologia

🏷️ Credits

Created and maintained by Castello Branco Tecnologia

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  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
1.0.1 211 4/23/2025