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.

VisualStudio confuses Avalonia XAML files with WPF XAML

See original GitHub issue

Update: Workaround - use .axaml file extension instead of .xaml.

I created a custom Window this way:

namespace MyProject.Desktop.Views
    public abstract class BaseWindow : Window
        public BaseWindow()

        protected void InitializeComponent()


Now I use it in my views:




In MainWindow.xaml.cs, the view is declared as

namespace SparkEvo.Desktop.Views.Main
    public partial class MainWindow : BaseWindow

At this point, the XAML designer in Visual Studio 2017 gets full of errors… immagine

It does not recognize the tags anymore (“The type XXXX was not found. Verify that you are not missing an assembly reference.”). But…

  • If I make MainWindow a simple Window, so that it does not extend BaseWindow, the error disappears.
  • I can compile even with this error, but the XAML designer is unusable, example there is no autocomplete and working gets really difficult.

Avalonia version: 0.8.0 Target Frameworks: netcoreapp2.2;net461

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

grokyscommented, Nov 27, 2019

#111 contains a workaround for this issue. It doesn’t fix the underlying issue but at least allows you to open a XAML file with the Avalonia editor from the “Open With…” menu. Thanks @donandren for coming up with this.

grokyscommented, Oct 11, 2019

@stevenbrix yeah, the problem is this:

Visual Studio works on the xmlns of the root element, not the root xmlns declaration. Because BaseWindow is not in the namespace, it gives up and shows the WPF designer 😦

So it’s showing the WPF designer instead of ours because base:BaseWindow is in the clr-namespace:MyProject.Desktop.Views and not in the avalonia namespace.

IMO it should be looking at the xmlns="" namespace to decide which designer to show, not the namespace of the root element.

@waliarubal we originally did that, but that caused other problems IIRC (I can’t remember the details right now). Also they’re XAML files, we shouldn’t have to come up with our own extension 😉 This is 100% a bug in VS that should be fixed IMO.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Avalonia XAML
These pages will introduce you to how XAML is used specifically in Avalonia UI. For background information about how XAML is used elsewhere...
Read more >
WinForms, WPF, Avalonia or something else? : r/csharp
Avalonia is similar enough that you can always pick it up later if you want. Start with learning XAML and just using event...
Read more >
Porting WPF to AvaloniaUI - jammer
A write up of developer experience in porting a large complex WPF application to cross-platform AvaloniaUI and .NET 6.
Read more >
I can't use blend for visual studio 2022 to edit axaml
Hello, I'm studying Avalonia UI to migrate my wpf app. so, I created Avalonia mvvm project and open it in blend for VS...
Read more >
The call is ambiguous between the following methods
I had this issue when copying my XAML between controls. I just had to change my x:Class="mynamespace" where mynamespace is the proper ...
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 Post

No results found

github_iconTop Related Hashnode Post

No results found