[templates] do not use 'required' in xaml controls#31564
Merged
StephaneDelcroix merged 2 commits intonet10.0from Sep 16, 2025
Merged
[templates] do not use 'required' in xaml controls#31564StephaneDelcroix merged 2 commits intonet10.0from
StephaneDelcroix merged 2 commits intonet10.0from
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR addresses a compatibility issue with the required keyword in XAML controls within .NET MAUI templates. The runtime XAML and XamlC systems ignore required fields and properties, making the compiler check ineffective. The change replaces compile-time required validation with runtime null checks.
- Removes
requiredmodifiers from DataTemplate properties in ChipDataTemplateSelector - Adds runtime null validation with descriptive error messages when templates are accessed
src/Templates/src/templates/maui-mobile/Pages/Controls/ChipDataTemplateSelector.cs
Outdated
Show resolved
Hide resolved
src/Templates/src/templates/maui-mobile/Pages/Controls/ChipDataTemplateSelector.cs
Outdated
Show resolved
Hide resolved
Runtime XAML and XamlC inflators ignore the required fields and props. XSG can do it in soem cases but fails for complex, or long references. Replace the compiler check (ignored) by a runtime check
3f82e8e to
e2a9e90
Compare
Member
|
We need to also update this in the maui-samples repo |
src/Templates/src/templates/maui-mobile/Pages/Controls/ChipDataTemplateSelector.cs
Outdated
Show resolved
Hide resolved
…aTemplateSelector.cs
jfversluis
approved these changes
Sep 16, 2025
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.
Runtime XAML and XamlC inflators ignore the required fields and props. XSG can do it in soem cases but fails for complex, or long references. Replace the compiler check (ignored) by a runtime check