Skip to content

.Net Maui Save error: 'x' is an undeclared prefix if using MauiAllowImplicitXmlnsDeclaration #556

Description

@alistair-ocad

Describe the bug
When saving a .Net Maui xaml file the error " 'x' is an undeclared prefix " appears. This is when using implicit namespaces.

To Reproduce

  1. Create a .Net Maui project

  2. Add this to the project file:
    <PropertyGroup> <!-- First, enable preview feature flag --> <EnablePreviewFeatures>true</EnablePreviewFeatures> <!-- Then, opt-in for the implicit namespace feature --> <DefineConstants>$(DefineConstants);MauiAllowImplicitXmlnsDeclaration</DefineConstants> </PropertyGroup>

  3. Create a client page/view.

  4. Remove:
    xmlns="http://schemas.microsoft.com/dotnet/2021/maui" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"

  5. According to the documentation these should not be necessary.
    See: https://devblogs.microsoft.com/dotnet/simpler-xaml-in-dotnet-maui-10/

  6. Save, and the error message appears.

  7. What's more, the code compiles and runs perfectly without these two lines.

Expected behavior
The file will save, accepting the missing "x:..." declaration, preferably understanding that "MauiAllowImplicitXmlnsDeclaration" is being used. Or have an option in the XamlStyler to ignore these.

Screenshots

Image

Version Info (please complete the following information):

  • Windows 11
  • Visual Studio: 2026
  • XAML Styler: version 3.2501.8
  • .Net 10

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions