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

Previewer shows nothing if ViewModel has parameters in constructor. #434

Closed
davi2td opened this issue Sep 24, 2024 · 2 comments
Closed

Previewer shows nothing if ViewModel has parameters in constructor. #434

davi2td opened this issue Sep 24, 2024 · 2 comments

Comments

@davi2td
Copy link

davi2td commented Sep 24, 2024

Avalonia rider plugin 1.5.1
JetBrains Rider 2024.2.5

This was a bit annoying and decided to look into this.
I'm opening this because this issue : #209 while similar is specific to datacontext.
In my case, and was referenced in #209, by @SKProCH, to break preview simply do the following :
Create a standard window with a simple constructor:
public partial class Window1 : Window

{
    public Window1(string title)
    {
        InitializeComponent();
    }
}

Rebuild open and you will have nothing in preview, including no errors.
Pretty sure this has been there for some time, happy to help.
Thanks
-TD

@davi2td
Copy link
Author

davi2td commented Sep 24, 2024

ok not an intuitive error in idea.log , at least not IServiceProvider ...
WARN - #me.fornever.avaloniarider.idea.editor.BitmapPreviewEditorComponent - XAML update error: InvalidOperationException: Cannot compile Build method. Parameters mismatch.Type needs to have a parameterless ctor or a ctor with a single IServiceProvider argument.Or x:Arguments directive with matching arguments needs to be set

Apparently a parameterless constructor is required regardless of any others for preview to work ? Is this documented because not obvious initially.

public Window1()
{
    InitializeComponent();
}
public Window1(string title)
{
    InitializeComponent();
}

@davi2td davi2td closed this as completed Sep 24, 2024
@ForNeVeR
Copy link
Owner

ForNeVeR commented Sep 24, 2024

There are plans to show errors like this one directly in the UI. Sorry!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants