https://github.com/nickelony/custommessagebox.avalonia
A highly customizable MessageBox pop-up for Avalonia with pre-set and custom buttons and plenty of layout options.
https://github.com/nickelony/custommessagebox.avalonia
avalonia avaloniaui messagebox popup
Last synced: 8 months ago
JSON representation
A highly customizable MessageBox pop-up for Avalonia with pre-set and custom buttons and plenty of layout options.
- Host: GitHub
- URL: https://github.com/nickelony/custommessagebox.avalonia
- Owner: Nickelony
- License: mit
- Created: 2023-09-26T09:48:23.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-10-09T23:57:31.000Z (over 2 years ago)
- Last Synced: 2025-01-31T07:03:01.812Z (over 1 year ago)
- Topics: avalonia, avaloniaui, messagebox, popup
- Language: C#
- Homepage: https://www.nuget.org/packages/CustomMessageBox.Avalonia
- Size: 175 KB
- Stars: 9
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Custom MessageBox for Avalonia
A highly customizable MessageBox pop-up for Avalonia with pre-set and custom buttons and plenty of layout options.
# Examples
Fluent:


Simple:


```cs
MessageBox.Show(
"This is a traditional message box with an \"OK\" button.",
"Traditional 1", MessageBoxButtons.OK);
```
---

```cs
MessageBoxResult result = MessageBox.Show(
"This is a traditional message box with \"YesNoCancel\" buttons.",
"Traditional 2",
MessageBoxButtons.YesNoCancel,
MessageBoxIcon.Question,
MessageBoxDefaultButton.Button1,
"accent");
```
---

```cs
var messageBox = new MessageBox(
"This is a traditional message box with \"YesNo\" buttons.\n" +
"The buttons are aligned to the center.",
"Traditional 3", MessageBoxIcon.Information)
{
HorizontalButtonsPanelAlignment = HorizontalAlignment.Center
};
var result = messageBox.Show(MessageBoxButtons.YesNo, MessageBoxDefaultButton.Button1, "accent");
```
---

```cs
var bitmap = new Bitmap(AssetLoader.Open(new Uri("avares://CustomMessageBox.Avalonia.Demo/Assets/avalonia-logo.ico")));
var messageBox = new MessageBox(
"This is a traditional message box with \"YesNo\" buttons.\n" +
"The message contains a custom icon with its size set to 64 x 64.",
"Traditional 6", bitmap)
{
IconWidth = 64,
IconHeight = 64
};
var result = messageBox.Show(MessageBoxButtons.YesNo, MessageBoxDefaultButton.Button1, "accent");
```
---

```cs
var textBlock = new TextBlock
{
Text = "This is a custom message box with \"YesNoCancel\" buttons.\n" +
"The buttons are displayed vertically and to the left.",
TextAlignment = TextAlignment.Center
};
var messageBox = new MessageBox(textBlock, "Custom 1", MessageBoxIcon.Error)
{
DialogContentOrientation = Orientation.Horizontal,
MessagePanelOrientation = Orientation.Vertical,
ButtonsPanelOrientation = Orientation.Vertical,
IconWidth = 192,
IconHeight = 192
};
var result = messageBox.Show(
new MessageBoxButton(MessageBox.YesText, MessageBoxResult.Yes, SpecialButtonRole.IsDefault, "accent"),
new MessageBoxButton(MessageBox.NoText, MessageBoxResult.No),
new MessageBoxButton(MessageBox.CancelText, MessageBoxResult.Cancel, SpecialButtonRole.IsCancel)
);
```
---

```cs
var textBlock = new TextBlock
{
Text = "This is a custom message box with custom buttons.\n" +
"The icon is displayed above the text.",
TextAlignment = TextAlignment.Center
};
var messageBox = new MessageBox(textBlock, "Custom 2", MessageBoxIcon.Information)
{
MessagePanelOrientation = Orientation.Vertical,
HorizontalButtonsPanelAlignment = HorizontalAlignment.Center,
MinButtonWidth = 125
};
var result = messageBox.Show(
new MessageBoxButton("Yes, Confirm", MessageBoxResult.Yes, SpecialButtonRole.IsDefault, "accent"),
new MessageBoxButton("No, Cancel", MessageBoxResult.Cancel, SpecialButtonRole.IsCancel)
);
```
---

```cs
var textBlock = new TextBlock
{
Text = "This is a custom message box with custom buttons.\n\n" +
"The buttons are displayed vertically and on the bottom.\n" +
"The icon is displayed above the text.",
TextAlignment = TextAlignment.Center
};
var messageBox = new MessageBox(textBlock, "Custom 3", MessageBoxIcon.Warning)
{
MessagePanelOrientation = Orientation.Vertical,
HorizontalButtonsPanelAlignment = HorizontalAlignment.Center,
ButtonsPanelOrientation = Orientation.Vertical
};
CustomMessageBoxResult result = messageBox.Show(
new MessageBoxButton("Accept", CustomMessageBoxResult.Accept, SpecialButtonRole.None, "accent"),
new MessageBoxButton("Decline", CustomMessageBoxResult.Decline)
);
```
---

```cs
var bitmap = new Bitmap(AssetLoader.Open(new Uri("avares://CustomMessageBox.Avalonia.Demo/Assets/avalonia-logo.ico")));
var messageBox = new MessageBox(
"This is a custom message box with custom buttons.\n" +
"The icon is custom and is displayed above the text.",
"Custom 4", bitmap)
{
DialogContentOrientation = Orientation.Horizontal,
MessagePanelOrientation = Orientation.Vertical,
ButtonsPanelOrientation = Orientation.Vertical,
IconWidth = 256,
IconHeight = 256
};
int result = messageBox.Show(
new MessageBoxButton("English", 1),
new MessageBoxButton("Polish", 2),
new MessageBoxButton("German", 3),
new MessageBoxButton("Spanish", 4),
new MessageBoxButton("Italian", 5),
new MessageBoxButton("French", 6),
new MessageBoxButton("Chinese", 7)
);
```