[Proposal] Xmlns Definition
See original GitHub issueAdd Xmlns Definition
- Proposed
- Prototype
- Implementation
- iOS Support
- Android Support
- macOS Support
- Windows Support
- Unit Tests: (Not Required)
- Sample
- Documentation
Link to Discussion
https://github.com/CommunityToolkit/Maui/discussions/144
Summary
This proposal will result in reducing the number of xmlns
declarations required in XAML files when using different parts of the toolkit. It would result in only needing to use a single declaration e.g.
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/tookit"
Motivation
To reduce the number of xmlns
declarations required in XAML files.
Detailed Design
More implementation detail than design but we should just require adding this for each part of the namespace:
[assembly: XmlnsDefinition("http://schemas.microsoft.com/dotnet/2022/maui/tookit", "CommunityToolkit.Maui.Behaviors")]
[assembly: XmlnsDefinition("http://schemas.microsoft.com/dotnet/2022/maui/tookit", "CommunityToolkit.Maui.Converters")]
// ...
Usage Syntax
XAML Usage
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2021/maui/tookit"
x:Class="MauiApp2.MainPage">
</ContentPage>
Drawbacks
There has been a discussion around whether this could introduce the linking issue that we saw in XCT (https://github.com/xamarin/XamarinCommunityToolkit/issues/1311) however it is believed that this should not be an issue in the Maui Community Toolkit given we will actually have to call code that will prevent the linker from removing it.
Alternatives
Do nothing?
Unresolved Questions
N/A
Issue Analytics
- State:
- Created 2 years ago
- Comments:10 (8 by maintainers)
Top GitHub Comments
Given we now have our docs repository setup this change will drastically simplify the writing of the docs. I think this alone also then shows how it would simplify writing XAML in apps 😃
Please vote:
Docs completed at: https://github.com/MicrosoftDocs/CommunityToolkit/blob/main/docs/maui/get-started.md