2

I am trying to navigate to page "TestView" which is in folder "Views" of my VisualStudio solution. Here the compile Error.

Error XFC0000 Cannot resolve type ":TestView"

AppShell.xaml file

<FlyoutItem Title="test" FlyoutIcon="List">

        <ShellContent
        Title="Test Page"
        ContentTemplate="{DataTemplate local:TestView}"
        Route="TestView" />
    </FlyoutItem>

Need Help to solve the Compile Error

Here the link to my GitHub project MPC-Calculator Maui Branch

enter image description here

Jean-Marc Flamand
  • 939
  • 3
  • 10
  • 24

2 Answers2

4

Change your namespace in your shell from:

xmlns:local="clr-namespace:MPC_MassPropertiesCalculator_MAUIapp"

To this:

xmlns:local="clr-namespace:MPC_MassPropertiesCalculator_MAUIapp.Views"

Basically if you wanna refer a View in your XAML you need to have its exact namespace and then the name of your View.

halfer
  • 19,824
  • 17
  • 99
  • 186
FreakyAli
  • 13,349
  • 3
  • 23
  • 63
  • 1
    Thanks problem solve using your proposal. – Jean-Marc Flamand Oct 19 '22 at 13:40
  • 1
    Happy to help, If you are looking for extended MAUI controls for Android and iOS you can check my lib out : https://github.com/FreakyAli/Maui.FreakyControls – FreakyAli Oct 19 '22 at 13:42
  • 1
    final fix is xmlns:local="clr-namespace:MPC_MassPropertiesCalculator_MAUIapp", xmlns:page="clr-namespace:MPC_MassPropertiesCalculator_MAUIapp.Views" ..... ContentTemplate="{DataTemplate page:TestView}" ..... – Jean-Marc Flamand Oct 19 '22 at 13:42
  • OMG this helped me a lot.. new to maui and spend 2-3hrs before I bumped on this. Thank you:) – Scorpy47 Feb 15 '23 at 23:15
1

As mentioned, you can update the name of the local namespace or define a new one.

For example, add this to the Shell

xmlns:mynamespace="clr-namespace:MPC_MassPropertiesCalculator_MAUIapp.Views" and then you can use it with

<FlyoutItem Title="test" FlyoutIcon="List">
        <ShellContent
        Title="Test Page"
        ContentTemplate="{DataTemplate mynamespace:TestView}"
        Route="TestView" />
</FlyoutItem>