Description
Add Xmlns Definition
- Proposed
- Prototype
- Implementation
- iOS Support
- Android Support
- macOS Support
- Windows Support
- Unit Tests: (Not Required)
- Sample
- Documentation
Link to Discussion
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 (xamarin/XamarinCommunityToolkit#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