Repository navigation
[Net11] Fix Maui.Controls.Sample build fails with MAUIG2045 - #36882
Merged
Merged
Conversation
devanathan-vaithiyanathan
temporarily deployed
to
copilot-pat-pool
July 28, 2026 14:49 — with
GitHub Actions
Inactive
Contributor
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 36882Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 36882" |
|
Azure Pipelines: Successfully started running 1 pipeline(s). There may be pipelines that require an authorized user to comment /azp run to run. |
devanathan-vaithiyanathan
temporarily deployed
to
copilot-pat-pool
July 28, 2026 14:50 — with
GitHub Actions
Inactive
devanathan-vaithiyanathan
temporarily deployed
to
copilot-pat-pool
July 28, 2026 14:52 — with
GitHub Actions
Inactive
devanathan-vaithiyanathan
temporarily deployed
to
copilot-pat-pool
July 28, 2026 14:54 — with
GitHub Actions
Inactive
devanathan-vaithiyanathan
temporarily deployed
to
copilot-pat-pool
July 28, 2026 14:55 — with
GitHub Actions
Inactive
devanathan-vaithiyanathan
temporarily deployed
to
copilot-pat-pool
July 28, 2026 14:56 — with
GitHub Actions
Inactive
sheiksyedm
marked this pull request as ready for review
July 28, 2026 15:10
|
Azure Pipelines: Successfully started running 1 pipeline(s). There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the MAUI Controls sample pages to avoid MAUIG2045 build failures introduced by stricter compiled-binding diagnostics, by ensuring RelativeSource AncestorType points to the concrete page type (views:BasePage) that actually defines SelectedItem/NavigateCommand (instead of the base ContentPage type which the source generator cannot attribute those members to).
Changes:
- Replaced
AncestorType={x:Type ContentPage}withAncestorType={x:Type views:BasePage}forSelectedItemandSelectionChangedCommandbindings across multiple sample pages. - Minor XAML formatting cleanups (indentation/self-closing tag spacing) in the touched pages.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/Controls/samples/Controls.Sample/Pages/UserInterfacePage.xaml | Update RelativeSource ancestor type to views:BasePage for selection/navigation bindings. |
| src/Controls/samples/Controls.Sample/Pages/PlatformSpecificsPage.xaml | Update RelativeSource ancestor type to views:BasePage for selection/navigation bindings. |
| src/Controls/samples/Controls.Sample/Pages/OthersPage.xaml | Update RelativeSource ancestor type to views:BasePage and apply minor XAML formatting in the footer section. |
| src/Controls/samples/Controls.Sample/Pages/MainPage.xaml | Update SelectedItem binding to use views:BasePage as the RelativeSource ancestor type. |
| src/Controls/samples/Controls.Sample/Pages/LayoutsPage.xaml | Update RelativeSource ancestor type to views:BasePage for selection/navigation bindings. |
| src/Controls/samples/Controls.Sample/Pages/Layouts/ScrollViewPage.xaml | Update RelativeSource ancestor type to views:BasePage for selection/navigation bindings and minor formatting. |
| src/Controls/samples/Controls.Sample/Pages/CustomFlyoutPage.xaml | Update RelativeSource ancestor type to views:BasePage within the flyout page content. |
| src/Controls/samples/Controls.Sample/Pages/CorePage.xaml | Update RelativeSource ancestor type to views:BasePage for selection/navigation bindings. |
| src/Controls/samples/Controls.Sample/Pages/Core/GesturesPage.xaml | Update RelativeSource ancestor type to views:BasePage for selection/navigation bindings. |
| src/Controls/samples/Controls.Sample/Pages/ControlsPage.xaml | Update RelativeSource ancestor type to views:BasePage for selection/navigation bindings. |
| src/Controls/samples/Controls.Sample/Pages/CompatibilityPage.xaml | Update RelativeSource ancestor type to views:BasePage for selection/navigation bindings. |
| src/Controls/samples/Controls.Sample/Pages/Compatibility/ListViewPage.xaml | Update RelativeSource ancestor type to views:BasePage for selection/navigation bindings (the reported failure site). |
kubaflo
approved these changes
Jul 28, 2026
2 tasks
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue Details
After merging regression PR #32905 – [XSG] Improve diagnostic reporting during binding compilation, XAML bindings that were previously ignored during source-generated binding compilation started failing the build. The issue was observed in bindings that used:
AncestorType={x:Type ContentPage}
The build now fails with MAUIG2045, which is treated as an Error.
Previously, the source generator silently skipped unsupported or invalid bindings without reporting diagnostics, so these bindings did not block the build.
Description of Change
PR #32905 updated the binding source generator to report diagnostics instead of silently ignoring invalid bindings.
Previous behavior
Updated behavior
The PR introduced six new MAUIG diagnostics that align with the older XamlC XC* diagnostics, improving diagnostic visibility during binding compilation.
Because MAUIG2045 is emitted as an Error, bindings using AncestorType={x:Type ContentPage} now fail compilation. To resolve the issue, the bindings were updated to use the correct view type:
AncestorType={x:Type views:BasePage}
This change restores successful compilation while preserving the new diagnostic behavior introduced by PR #32905.
Issues Fixed
Fixes #36827