Avalonia UI: Issue with code generation
Hello everyone. I am new to C# and am attempting to learn Avalonia. I tried to follow the guide on Avalonia's website for the To Do List app, but I got stuck on making a new view. I am using VS 2022 and I am getting the following error when creating the new view
ToDoListView.axaml.cs
:
CS0103: The Name 'Initialize Component' does not exist in the current context
However, the default MainView
provided with the solution template has identical code-behind with the obvious exception of differing class names.
I suspect this is an issue with code generation, but I'm not sure how I would determine this. Has anyone encountered this before?4 Replies
Probably need to share the code of your ToDoListView.axaml and ToDoListview.axaml.cs
Of course. Here is
ToDoListView.axaml
:
And here is ToDoListView.axaml.cs
:
Locked down my error. It was the 6th line in ToDoListView.axaml
. It was refererring to a type in the wrong namespace. It should have been M2ASCII.Views.ToDoListView
instead of M2ASCII.ToDoListView
Ah weird, did you manually type that in rather than letting it autogenerate then?
Yeah, quite often refactor-rename on the codebehind / namespace doesn't update the XAML files