Skip to content

fix: enable compiled Source binding to resolve XamlC XC0025 in TodoApp.MAUI#554

Merged
adrianhall merged 2 commits into
CommunityToolkit:mainfrom
adrianhall:issues/517
Jul 10, 2026
Merged

fix: enable compiled Source binding to resolve XamlC XC0025 in TodoApp.MAUI#554
adrianhall merged 2 commits into
CommunityToolkit:mainfrom
adrianhall:issues/517

Conversation

@adrianhall

Copy link
Copy Markdown
Collaborator

Summary

Fixes #517.

MainPage.xaml's Entry.ReturnCommandParameter binds via an explicit Source={x:Reference addItemEntry} instead of the page's BindingContext. By default, XamlC skips compiling any binding with an explicit Source, which produced this build warning (performance-only, no functional impact):

MainPage.xaml(58,25): XamlC warning XC0025: Binding was not compiled because it has an explicitly set Source property and compilation of bindings with Source is not enabled. ...

Fix

Per current .NET MAUI docs on compiling Source bindings:

  1. TodoApp.MAUI.csproj: opt in to <MauiEnableXamlCBindingWithSourceCompilation>true</MauiEnableXamlCBindingWithSourceCompilation> project-wide, with a comment explaining why and confirming this is the only Source-based binding in the project (so there's no risk of newly-surfaced x:DataType mismatches elsewhere, per the doc's own caution about this being an opt-in feature).
  2. MainPage.xaml: annotate the binding itself with the documented inline x:DataType=Entry so XamlC has the type info it needs to compile it: {Binding Text, Source={x:Reference addItemEntry}, x:DataType=Entry}.

This avoids any XAML restructuring — no DataTemplate/binding-scope changes needed, since MAUI 9+ supports annotating the Binding markup extension directly.

Verification

Local verification wasn't possible (macOS host, no MAUI workloads installed, no Windows target available), so I triggered build-samples.yml manually via workflow_dispatch on the fork and inspected the raw job logs:

  • todoapp-windows / build (the job that originally surfaced this warning): run0 occurrences of XC0025 in the build log; only the pre-existing, unrelated CS0618 ListView is obsolete warning remains (same warning present before this change).
  • todoapp-maui / android and todoapp-maui / ios: also clean — no XC0025, no new XC00xx warnings.
  • All 18 jobs in the build-samples.yml run passed.

Related

ahall and others added 2 commits July 10, 2026 19:25
…p.MAUI

MainPage.xaml's Entry.ReturnCommandParameter binds via an explicit
Source={x:Reference addItemEntry}, which XamlC does not compile by
default, producing a build warning (XC0025) and falling back to
slower reflection-based binding.

Enable MauiEnableXamlCBindingWithSourceCompilation project-wide and
annotate the binding with x:DataType=Entry so XamlC can compile it.
This is the only Source-based binding in the project, so no other
bindings are affected.

Fixes CommunityToolkit#517
@adrianhall adrianhall merged commit f8bc030 into CommunityToolkit:main Jul 10, 2026
20 checks passed
@adrianhall adrianhall deleted the issues/517 branch July 10, 2026 18:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TodoApp.MAUI: MainPage.xaml binding not compiled due to explicit Source (XamlC XC0025)

1 participant