Consolonia.Modal
12.0.3.62
dotnet add package Consolonia.Modal --version 12.0.3.62
NuGet\Install-Package Consolonia.Modal -Version 12.0.3.62
<PackageReference Include="Consolonia.Modal" Version="12.0.3.62" />
<PackageVersion Include="Consolonia.Modal" Version="12.0.3.62" />
<PackageReference Include="Consolonia.Modal" />
paket add Consolonia.Modal --version 12.0.3.62
#r "nuget: Consolonia.Modal, 12.0.3.62"
#:package Consolonia.Modal@12.0.3.62
#addin nuget:?package=Consolonia.Modal&version=12.0.3.62
#tool nuget:?package=Consolonia.Modal&version=12.0.3.62
Consolonia.Modal
Consolonia.Modal provides a mechanism for displaying modal dialogs in Consolonia applications.
Features
- Modal Overlay: Shades the background to prevent interaction with the main window.
- Integration: Use
ModalThemeto enable modal support for all windows. - Customization: Control the title, icon, close button visibility, and keyboard behavior (Escape key).
- Layout: Modal size and position are determined by the
ModalWindowproperties and its first child.
Installation
Add the Consolonia.Modal package to your project and include the ModalTheme in your App.axaml:
<Application ...
xmlns:console="https://github.com/consolonia"
xmlns:modal="clr-namespace:Consolonia.Modal;assembly=Consolonia.Modal">
<Application.Styles>
<console:ModernTheme />
<modal:ModalTheme />
</Application.Styles>
</Application>
The ModalTheme attaches a ModalHost to every Window, which is required for displaying modal dialogs.
Usage
1. Create a Modal Window
Create a new XAML file for your modal, inheriting from modal:ModalWindow. Set alignment on the ModalWindow itself to control its position.
<modal:ModalWindow xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:modal="clr-namespace:Consolonia.Modal;assembly=Consolonia.Modal"
x:Class="MyApp.MyModal"
Title="Confirmation"
Icon="❓"
HorizontalAlignment="Center"
VerticalAlignment="Center">
<StackPanel Spacing="1">
<TextBlock Text="Are you sure you want to proceed?" />
<StackPanel Orientation="Horizontal" Spacing="2" HorizontalAlignment="Center">
<Button Content="OK" Click="OnOkClick" />
<Button Content="Cancel" Click="OnCancelClick" />
</StackPanel>
</StackPanel>
</modal:ModalWindow>
2. Show the Modal
Call ShowModalAsync from your code-behind:
var modal = new MyModal();
await modal.ShowModalAsync(this); // 'this' is the parent window or control
Layout and Alignment
A ModalWindow spans the entire parent window by default to provide the modal overlay. The actual "modal box" (the frame with the title and borders) follows the size of the first child and is centered within the ModalWindow.
The Role of the First Child
The size of the modal frame depends on the first child of the ModalWindow.
- Sizing: The modal frame automatically calculates its size based on the dimensions of the first child.
- Alignment: The first child must have its
HorizontalAlignmentandVerticalAlignmentset toStretch(the default). Setting them toCenteror other values will cause layout issues. - Margins: Avoid setting a
Marginon the first child, as it will behave like padding inside the modal frame.
Positioning the Modal
To control the position, size, or margins of the modal box relative to the screen, set these properties on the ModalWindow itself:
- Centering: Set
HorizontalAlignment="Center"andVerticalAlignment="Center"on theModalWindow. - Margins: Set
Marginon theModalWindowto add space between the overlay edges and the modal. - Docking: Use
Left,Right,Top, orBottomalignments on theModalWindow.
Properties
| Property | Type | Description |
|---|---|---|
Title |
string |
The text displayed in the modal header. |
Icon |
object |
An icon displayed next to the title. |
IsCloseButtonVisible |
bool |
Whether to show the [x] close button (Default: true). |
CancelOnEscape |
bool |
Whether the modal can be closed by pressing the Escape key (Default: true). |
Margin |
Thickness |
Should be used on the ModalWindow itself to limit the modal area. |
Customizing Themes
Consolonia.Modal supports both Modern and TurboVision themes. The ModalTheme automatically picks the appropriate styles based on the active Consolonia theme.
If you need to customize the look of all modals, you can override the ControlTheme for modal:ModalWindow or modal:ModalWindowHeader.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. 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. |
-
net8.0
- Avalonia (>= 12.0.3)
- Consolonia.Core (>= 12.0.3.12)
- Consolonia.Themes (>= 12.0.3.12)
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 |
|---|---|---|
| 12.0.3.62 | 114 | 8/27/2026 |
| 12.0.3.58-alpha.58 | 53 | 8/25/2026 |
| 12.0.3.57-alpha.57 | 64 | 8/25/2026 |
| 12.0.3.56-alpha.56 | 63 | 8/25/2026 |
| 12.0.3.47 | 166 | 8/10/2026 |
| 11.3.12.5 | 344 | 4/16/2026 |