Consolonia.Blazor
v11.2.3-beta.802Pre-release
net8.0
Text User Interface implementation of Avalonia UI (GUI Framework)
Published
Jan 17, 2025
1y ago
Total Downloads
23.3K
23,298
Install
dotnet add package Consolonia.Blazor --version 11.2.3-beta.802
| Product | Versions |
|---|---|
| .NET |
README
Consolonia.Blazor
This package provides the ability to use Blazor .razor files to create Consolonia applications.
- Use β‘ Blazor syntax for Avalonia apps
- π Simpler syntax than XAML
- πͺ IntelliSense support
- Get free π₯ Hot Reload support on-top
- See https://github.com/Epictek/Avalonia-Blazor-Bindings
Background
Consolonia is a TUI (Text User Interface) (GUI Framework) implementation for Avalonia UI
Showcase (click picture to see video)
Example Razor file
Things to note:
- Method binding to code behind
- Conditional layout of elements
- Full intellisense for renaming going to code behind autocomplete etc.
- injection of INavigation so you can push and pop views off of the nav stack
- injection of IClassicDesktopStyleApplicationLifetime so you can access Args and shutdown the app.
- HOT RELOAD. simple save the file and your view gets rebuilt and rerendered!
@page "/"
@inject INavigation navigation
@inject IClassicDesktopStyleApplicationLifetime lifetime
@namespace Example.Blazor.Components
<Window Title="Blazor Bindings for Consolonia" Topmost="true">
<StackPanel Orientation="Orientation.Vertical" VerticalAlignment="VerticalAlignment.Center">
@if (showCounter)
{
<TextBlock HorizontalAlignment="HorizontalAlignment.Center">Counter: @CounterText</TextBlock>
}
<StackPanel Orientation="Orientation.Vertical" HorizontalAlignment="HorizontalAlignment.Center" Margin="@Thickness.Parse("4")">
<Button OnClick="@OnIncrement">Increment counter support</Button>
<Button OnClick="@OnToggleCounter">@ToggleText</Button>
<Button OnClick="@OnMessageBox">Message Box</Button>
<Button OnClick="@OnGotoSubPage">Go to SubPage</Button>
<Button OnClick="@OnExit">Exit</Button>
</StackPanel>
</StackPanel>
</Window>
@code {
int counter = 0;
bool showCounter = true;
string CounterText => counter switch
{
0 => "Not clicked",
1 => $"Clicked 1 time",
_ => $"Clicked {counter} times"
};
string ToggleText => showCounter ? "Hide Counter" : "Show Counter";
void OnIncrement()
=> counter++;
void OnToggleCounter()
=> showCounter = !showCounter;
void OnGotoSubPage()
=> navigation.PushAsync<SubPage>();
async void OnMessageBox(RoutedEventArgs args)
{
await new MessageBox()
.ShowDialogAsync((AC.Control)args.Source!, "Hello, Blazor!", "Blazor Bindings for Consolonia");
}
void OnExit()
=> lifetime.Shutdown();
}
Changes from Previous Version
No structural changes between v11.2.3-beta.798 and v11.2.3-beta.802.
Adoption Assessment
Assess this package against its supported frameworks, license, maintenance signals and dependency graph before making it a project standard.
This version is marked prerelease. Validate its API and upgrade path before production use.Compatibility metadata lists 1 target framework; confirm the exact target used by your application.
Related Guides & Workflows
Learn how to evaluate, integrate, or audit this package in your .NET project.
