AvaloniaUI / XamlControlsGallery

MIT License
159 stars 30 forks source link

OpenFileDialog closes my application #14

Closed ilia19911 closed 3 years ago

ilia19911 commented 3 years ago

Hi. i am trying build my first application in avalonia with button which opens FileDialog. Then I click on the button, in axaml InvokeCommandAction is triggered and thereafter program opens ReactiveCommand. My code looks like this

async void RunOpenFile(string parameter)
{
    if (Avalonia.Application.Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
    {
        OpenFileDialog openFileDialog = new OpenFileDialog
        {
            Title = "Choose Images",
        };
        openFileDialog.Filters.Add(new FileDialogFilter { Name = "Images", Extensions = { "jpg", "png", "tif" } });
        await openFileDialog.ShowAsync( desktop.MainWindow);
    }
} 

But my application just closes without any exceptions.

OS: Ubuntu 20.04 FW: NET5 Avalonia version: 0.10.6

I will be glad for any help