question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Avalonia quickstart does not perform as expected

See original GitHub issue

Following the “Quickstart” instructions, it took about 5 seconds to get the WPF Quickstart working.

But I cannot for the life of me get the Avalonia demo to work.

NuGet package installs fine. this.Find in the .cs fails

This has wiggly underlines:

<ScottPlot:AvaPlot Name="AvaPlot1"/>

Not sure if the Quickstart code is out of date?

Issue Analytics

  • State:closed
  • Created 7 months ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
bclehmanncommented, Mar 1, 2023

what sort of project should I be making in VS? Avalonia? WPF? Blank?

Avalonia, the project template you use should match what you’re making. If you want to make a WPF app you use the WPF template, if you want to make an Avalonia app you use the Avalonia template.

I think I can access the blank Avalonia window thru the Add… option. But why would I do that? Avalonia is a project type that can be selected when creating a new project.

Avalonia projects have at least one window. The project template will create a project with one window (MainWindow.axaml and MainWindow.axaml.cs). If you still have those files feel free to place the ScottPlot control in the main window, I bring up window creation because it looks like you tried to create a window but something went wrong.

The “this” issue… perhaps that will go away if the window inherits from Avalonia.Controls.Window however it didn’t work for me.

Turning Program into a subclass of Window is not enough, it’s still not a valid window because Avalonia windows need to call AvaloniaXamlLoader.Load(this) in their constructors. It may get rid of the errors you saw but the application will not work at runtime. This is taken care of for you if you create a window from the template.

The WPF Quickstart is simple and works, but the Avalonia one could do with some clarifications 😃

It’s interesting that you mentioned the WPF quickstart, since the two frameworks are incredibly similar (to the point that copy-pasted WPF code often “just works” in Avalonia). Hence the two quickstarts are basically the same except for when the Avalonia quickstart needs to bring up namespaces.

In any case, your problem doesn’t seem to be “how do I add ScottPlot to my Avalonia project” so much as it is “how do I create an Avalonia project” since the issues you’re running into aren’t really related to ScottPlot. I would probably suggest copying this directory so you can jump ahead to actually working with ScottPlot and Avalonia. This is the source code for the quickstart, ripped from an old version of the ScottPlot website because I can’t find it on the new one.

0reactions
Resonanzcommented, Feb 28, 2023

Thanks for your comments. I’m sorry that I don’t understand XAML well enough to understand your answers.

First question is: what sort of project should I be making in VS? Avalonia? WPF? Blank?

Once the project is open, and NuGet packages are installed, then I think I can access the blank Avalonia window thru the Add… option. But why would I do that? Avalonia is a project type that can be selected when creating a new project.

The WPF Quickstart is simple and works, but the Avalonia one could do with some clarifications 😃

The “this” issue… perhaps that will go away if the window inherits from Avalonia.Controls.Window however it didn’t work for me.

The new files are named Window1.axaml and Window1.axaml.cs btw.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshooting
Below we will list common possible reasons and solutions. Selector targets a control that doesn't exist​. Avalonia selectors, like CSS selectors, do not...
Read more >
Unable to run published Avalonia app · Issue #1665
I'm new to Avalonia (and I understand Avalonia is still very much a work-in-progress), should I expect OSX to build and publish yet?...
Read more >
001. Avalonia UI - Getting Started Environment Setup - YouTube
Support me in my journey to giving back to the industry all my knowledge and helping the world with what I do. Spreading...
Read more >
ReactiveUI Example with Avalonia : UserControl View not ...
The assembly code scanning is working (at least on this date), but it looks like you are passing the wrong assembly.
Read more >
I finally ported from WPF to Avalonia! : r/dotnet
Quick write-up from an open-source developer and maintainer... might not be top quality content, but might help give a little perspective ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found