WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Add support for managed dialogs #329

@Sawa121212

Description

@Sawa121212

Avalonia provides managed dialogs.

image
After opening UseManagedSystemDialogs, OpenFileDialog opens abnormally. Add support for managed dialogs.

How to test:

  1. Add the UseManagedSystemDialogs() configuration to AppBuilder
  2. Test on dialog windows
    Example of calling a window:
private async Task OnImportPicture()
{
    if (Application.Current?.ApplicationLifetime is not IClassicDesktopStyleApplicationLifetime desktop ||
        desktop.MainWindow?.StorageProvider is not { } provider)
    {
        throw new NullReferenceException("Missing StorageProvider instance.");
    }

    IReadOnlyList<IStorageFile> files = await provider.OpenFilePickerAsync(new FilePickerOpenOptions
    {
        Title = "Choose File",
        AllowMultiple = false
    }).ConfigureAwait(true);

    if (files.Count >= 1)
    {
        string filePath = files[0].TryGetLocalPath();
        if (File.Exists(filePath))
        {
            Picture = filePath;
        }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions