.NET MAUI: wrong namespace in new ContentPage

Viewed 41

I have created a MAUI App with 'KnifeMaui' namespace.

Now when I add a new element->ContentPage it is generated with 'MauiApp1' namespace.

If I try to change it to 'KnifeMaui' I get an error for method InitializeComponent() (the name does not exists in the current context).

This is problem when in AppShell.xaml I try to set up an xmlns and it doesn't find KnifeMaui.Views.

I have looked in project properties but I haven't found any MauiApp1 reference.

Has anyone encountered this problem and fixed it?

2 Answers

To fix this you need to make changes in XAML and C# side of things since we have to link the two partials to each other

In XAML side look for :

    x:Class="YourNameSpace.YourClassName"

On your Code-Behind C#:

namespace YourNameSpace;

public partial class YourClassName : Shell (Shell ContentPage whatever)
{

Goodluck

Related