Skip to content

[XSG] RelativeSource without explicit Mode parsed as invalid '(none)' #33876

@StephaneDelcroix

Description

@StephaneDelcroix

Note

Are you waiting for the changes in this issue to be resolved?
Please check for existing PRs addressing this issue and test them if available.

Description

XSG fails to parse RelativeSource bindings when used with AncestorType but without an explicit Mode property. It parses the mode as '(none)' which is invalid.

Reproduction

<SwipeItem Command="{Binding Source={RelativeSource AncestorType={x:Type vm:MyViewModel}}, Path=MyCommand}" />

Error:

error MAUIG1001: An error occured while parsing Xaml: Invalid RelativeSource Mode '(none)'.

Expected Behavior

When Mode is not specified but AncestorType is, the mode should default to FindAncestor (as it does at runtime).

Affected File

src/Controls/samples/Controls.Sample/Pages/Controls/SwipeViewGalleries/SwipeViewBindingContextGallery.xaml

Workaround

Use Inflator="Runtime" for the affected XAML file, or explicitly specify Mode=FindAncestor.

Context

Discovered while testing XSG fixes for #33524.

Metadata

Metadata

Labels

s/triagedIssue has been revieweds/verifiedVerified / Reproducible Issue ready for Engineering TriagexsgXaml sourceGen

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions