Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MvvmDialogSample shows error with Avalonia 11.2.0 #106

Open
1 of 5 tasks
BiDuang opened this issue Nov 8, 2024 · 1 comment · May be fixed by #107
Open
1 of 5 tasks

MvvmDialogSample shows error with Avalonia 11.2.0 #106

BiDuang opened this issue Nov 8, 2024 · 1 comment · May be fixed by #107
Labels
bug Something isn't working

Comments

@BiDuang
Copy link

BiDuang commented Nov 8, 2024

Describe the bug

  • Typos in the docs
  • Missing information
  • Misleading or wrong information
  • Outdated links
  • Outdated or not working source code

Sample affected

  • MvvmDialogSample

Proposed solution

With the latest version of Avalonia and its dependencies (11.2.0), the file src/Avalonia.Samples/ViewInteraction/MvvmDialogSample/Views/InteractionView.axaml.cs fails to compile, returning Error CS1503.

As a workaround, downgrading the NuGet packages to version 11.1.0 resolves the issue.

@BiDuang BiDuang added the bug Something isn't working label Nov 8, 2024
@timunie timunie linked a pull request Nov 25, 2024 that will close this issue
8 tasks
@timunie
Copy link
Collaborator

timunie commented Nov 25, 2024

@BiDuang thanks for reporting this. Indeed, there was a change in ReactiveUI that I wasn't aware of. I filed a PR to fix it, however we are checking with the team if we need to revert this change or not.

Sorry for the inconvinience.

public partial class InteractionView : ReactiveUserControl<InteractionViewModel>
{
    public InteractionView()
    {
        InitializeComponent();

        this.WhenActivated(d =>
        {
-           d(ViewModel.SelectFilesInteraction.RegisterHandler(this.InteractionHandler));
+           d(ViewModel!.SelectFilesInteraction.RegisterHandler(this.InteractionHandler));
        });
    }

-    private async Task InteractionHandler(InteractionContext<string?, string[]?> context)
+    private async Task InteractionHandler(IInteractionContext<string?, string[]?> context)
    {
        // Get our parent top level control in order to get the needed service (in our sample the storage provider. Can also be the clipboard etc.)
        var topLevel = TopLevel.GetTopLevel(this);
        var storageFiles = await topLevel!.StorageProvider
            .OpenFilePickerAsync(
                        new FilePickerOpenOptions()
                        {
                            AllowMultiple = true,
                            Title = context.Input
                        });

-        context.SetOutput(storageFiles?.Select(x => x.Name).ToArray());
+        context.SetOutput(storageFiles.Select(x => x.Name).ToArray());
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants