Skip to content

VisualStateManager Setter Fails for Namespaced Custom Controls in .NET MAUI 10.0.0-preview.7 #31286

@PriyadharshniM

Description

@PriyadharshniM

Description

  • In .NET MAUI Preview 7, a custom control used in XAML fails to resolve at compile time (XC0000) when VisualStateManager with Setters is defined inside the control usage.

  • The same code compiles and runs in Preview 6, so this appears to be a regression in Preview 7’s XAML compiler/type resolution.

Expected behavior

The XAML compiler resolves customControl:MyBorder and compiles successfully.
VisualState setters apply at runtime.

Actual behavior

Build fails with XC0000 complaining it cannot resolve the custom control type.

Error output
XC0000: Cannot resolve type "http://schemas.microsoft.com/dotnet/2021/maui:MyBorder".
File: MainPage.xaml, line 17 (the custom control usage).

Image

Steps to Reproduce

  1. Create a new .NET MAUI app.
  2. Add a custom control class, e.g., MyBorder in namespace CustomBorder (assembly: TextSample), deriving from Border.
  3. Use the control in a XAML page with a clr-namespace mapping: xmlns:customControl="clr-namespace:CustomBorder;assembly=TextSample"
  4. Add VisualStateManager.VisualStateGroups with VisualState.Setters targeting a property such as Stroke inside the custom control element.
  5. Build the project (any target).

TestSample.zip

Link to public reproduction project repository

No response

Version with bug

10.0.0-preview.7

Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI

Last version that worked well

10.0.0-preview.6

Affected platforms

Windows

Affected platform versions

All Platform (Windows, Android, MacOS and iOS)

Did you find any workaround?

Use fully qualified property syntax in the setter:

<Setter Property="controls:MyBorder.Stroke" Value="Red" />

This workaround works in some cases but is inconsistent across platforms and scenarios.

Relevant log output

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions