Search code examples
mauimaui-windowsmaui-android

Maui Platform namespace is not recognised


I am implementing a project in my Maui app to display a pointer over buttons and links on Windows. (vladislavantonyuk.github.io/articles/Setting-a-cursor-for-.NET-MAUI-VisualElement/)

At the class CursorBehavior I need to import the platform -namespaces to use the method SetCustomCursor(..). Visual Studio knows, which namespaces are missing. enter image description here

After the (automatic) import of the namespaces, however, they are marked as faulty (on Android, MacCatalyst, Windows). enter image description here

Only for iOS the message is different: enter image description here

I tried also to set them all as global usings, what makes no differences.

Here as example the class CursorExtensions at Platforms.Android: enter image description here

How can I use the platform namespaces?


Solution

  • First of all, you can't add all the platforms namespace in the share project directly. You can only add one of them which depends on the target platform.

    Plugin.DeviceInfo.Abstractions

    Such as the picture shows, you can just add the Platforms.Android namespace.

    In addition, I checked the link you provided. You don't have to add all the platforms namespace. You can check the author's source code on the github.