© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
20 replies
Mek

✅ Creating An Accurate Loading Screen Avalonia

<Window xmlns="https://github.com/avaloniaui"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:vm="using:MeksMathGame.ViewModels"
        mc:Ignorable="d"
        x:Class="MeksMathGame.Views.SplashScreenView"
        x:DataType="vm:SplashScreenViewModel"
        Title="SplashScreenView"
        Width="220"
        Height="130"
        SystemDecorations="None"
        WindowStartupLocation="CenterScreen"
        TransparencyLevelHint="Transparent"
        TransparencyBackgroundFallback="Transparent">

    <Design.DataContext>
        <vm:SplashScreenViewModel />
    </Design.DataContext>

    <Border Background="#fff" CornerRadius="10" Padding="10">
        <StackPanel VerticalAlignment="Center" HorizontalAlignment="Center" Spacing="5">
            <Image Source="/Assets/avalonia-logo.ico" Width="50" Height="50" />
            <TextBlock Text="{Binding StartUpMessage}" />
            <Button HorizontalAlignment="Center" Command="{Binding Cancel}" Content="Cancel" />
        </StackPanel>
    </Border>
</Window>
<Window xmlns="https://github.com/avaloniaui"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:vm="using:MeksMathGame.ViewModels"
        mc:Ignorable="d"
        x:Class="MeksMathGame.Views.SplashScreenView"
        x:DataType="vm:SplashScreenViewModel"
        Title="SplashScreenView"
        Width="220"
        Height="130"
        SystemDecorations="None"
        WindowStartupLocation="CenterScreen"
        TransparencyLevelHint="Transparent"
        TransparencyBackgroundFallback="Transparent">

    <Design.DataContext>
        <vm:SplashScreenViewModel />
    </Design.DataContext>

    <Border Background="#fff" CornerRadius="10" Padding="10">
        <StackPanel VerticalAlignment="Center" HorizontalAlignment="Center" Spacing="5">
            <Image Source="/Assets/avalonia-logo.ico" Width="50" Height="50" />
            <TextBlock Text="{Binding StartUpMessage}" />
            <Button HorizontalAlignment="Center" Command="{Binding Cancel}" Content="Cancel" />
        </StackPanel>
    </Border>
</Window>
using ReactiveUI;
using System.Threading;

namespace MeksMathGame.ViewModels;

internal class SplashScreenViewModel : ViewModelBase
{
    private string _startUpMessage = "Application Is Loading. . .";
    private CancellationTokenSource _cts = new CancellationTokenSource();
    public CancellationToken cancellationToken => _cts.Token;

    public void Cancel()
    {
        _cts.Cancel();
    }

    public string StartUpMessage
    {
        get => _startUpMessage;
        set => this.RaiseAndSetIfChanged(ref _startUpMessage, value);
    }
}
using ReactiveUI;
using System.Threading;

namespace MeksMathGame.ViewModels;

internal class SplashScreenViewModel : ViewModelBase
{
    private string _startUpMessage = "Application Is Loading. . .";
    private CancellationTokenSource _cts = new CancellationTokenSource();
    public CancellationToken cancellationToken => _cts.Token;

    public void Cancel()
    {
        _cts.Cancel();
    }

    public string StartUpMessage
    {
        get => _startUpMessage;
        set => this.RaiseAndSetIfChanged(ref _startUpMessage, value);
    }
}
I'm starting my application off with a loading screen that shows on launch. How can I make this loading screen accurate like what you see on other applications. Loading resources, applying styles, etc.
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

❔ Creating A Share Button in avalonia
C#CC# / help
3y ago
✅ Resetting screen after *n* seconds Avalonia
C#CC# / help
3y ago
✅ Creating a ToolTip on a TextBox Avalonia
C#CC# / help
2y ago
✅ Issues with dynamically adding an icon from Avalonia.Icons.Material to an Avalonia ToggleButton
C#CC# / help
14mo ago