AvaloniaUI / Avalonia

Develop Desktop, Embedded, Mobile and WebAssembly apps with C# and XAML. The most popular .NET UI client technology
https://avaloniaui.net
MIT License
26.04k stars 2.25k forks source link

Issue when following Music Store App Guide #16506

Closed bitpoke-YT closed 3 months ago

bitpoke-YT commented 3 months ago

Describe the bug

When following the Guide and i get to Open a Dialog Vscode with the extension flags this.WhenActivated(d => d(ViewModel!.ShowDialog.RegisterHandler(DoShowDialogAsync))); for DoShowDialogAsync underlined with read This is what is said Argument 1: cannot convert from 'method group' to 'System.Action<ReactiveUI.IInteractionContext<MusicApp.ViewModels.MusicStoreViewModel, MusicApp.ViewModels.AlbumViewModel? and getting some error when trying to run or build

To Reproduce

Copy the code from the Guide on the website https://docs.avaloniaui.net/docs/tutorials/music-store-app/opening-a-dialog

Expected behavior

No response

Avalonia version

11.1.0

OS

Windows

Additional context

Sorry if it is not written well.

thevortexcloud commented 3 months ago

Can you share your full code for your code behind? It's likely a signature problem.

bitpoke-YT commented 3 months ago

Here is the Code it is the same as in the Guide

using Avalonia.ReactiveUI;
using ReactiveUI;
using MusicApp.ViewModels;
using System.Threading.Tasks;

namespace MusicApp.Views;

public partial class MainWindow : ReactiveWindow<MainWindowViewModel>
{
    public MainWindow()
    {
        InitializeComponent();
        this.WhenActivated(d => d(ViewModel!.ShowDialog.RegisterHandler(DoShowDialogAsync)));
    }
    private async Task DoShowDialogAsync(InteractionContext<MusicStoreViewModel, 
                                            AlbumViewModel?> interaction)
    {
        var dialog = new MusicStoreWindow();
        dialog.DataContext = interaction.Input;
        var result = await dialog.ShowDialog<AlbumViewModel?>(this);
        interaction.SetOutput(result);
    }
}
IanRawley commented 3 months ago

How about the ViewModel, specifically the definition of ShowDialog?