添加命令行参数,自定义扩展已经更新。
https://www.cnblogs.com/dalgleish/p/18972924

LoadFromCommandLine.axaml代码
<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" Height="300" Width="300" x:Class="AvaloniaUI.LoadFromCommandLine" Title="LoadFromCommandLine"> <Grid RowDefinitions="*,auto"> <TextBlock Name="Output"/> <Button Grid.Row="1" Click="LoadFile">加载命令行参数</Button> </Grid> </Window>
LoadFromCommandLine.axaml.cs代码
using Avalonia;
using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Markup.Xaml;
using Avalonia.Platform;
using Shares.Avalonia;
using System;
namespace AvaloniaUI;
public partial class LoadFromCommandLine : Window
{
public LoadFromCommandLine()
{
InitializeComponent();
}
private async void LoadFile(object? sender, RoutedEventArgs e)
{
Output.Text = await this.ReadAllTextAsync(this.GetCommandLine()![0]);
}
}
运行效果

浙公网安备 33010602011771号