diff --git a/src/Uno.Extensions.Maui.UI/MauiBinding.cs b/src/Uno.Extensions.Maui.UI/MauiBinding.cs
index c1f20e1d36..acddbb9d1a 100644
--- a/src/Uno.Extensions.Maui.UI/MauiBinding.cs
+++ b/src/Uno.Extensions.Maui.UI/MauiBinding.cs
@@ -2,21 +2,43 @@
namespace Uno.Extensions.Maui;
+///
+/// A binding extension for Maui apps.
+///
[ContentProperty(Name = nameof(Path))]
public class MauiBinding : MauiExtensionBase
{
+ ///
+ /// The path to the bound property.
+ ///
public string? Path { get; set; }
+ ///
+ /// The direction of the binding mode.
+ ///
public BindingMode BindingMode { get; set; } = BindingMode.Default;
+ ///
+ /// The string format of the bound property.
+ ///
public string? StringFormat { get; set; }
+ ///
+ /// The converter for the bound property.
+ ///
public object? Converter { get; set; }
+ ///
+ /// The parameter for the converter.
+ ///
public object? ConverterParameter { get; set; }
+ ///
+ /// The source object for the bound property.
+ ///
public object? Source { get; set; }
+ ///
protected override void SetValue(View view, Type viewType, Type propertyType, Microsoft.Maui.Controls.BindableProperty property, string propertyName)
{
if (string.IsNullOrEmpty(Path))
diff --git a/src/Uno.Extensions.Maui.UI/MauiColor.cs b/src/Uno.Extensions.Maui.UI/MauiColor.cs
index b099e5587b..ea49eb73a1 100644
--- a/src/Uno.Extensions.Maui.UI/MauiColor.cs
+++ b/src/Uno.Extensions.Maui.UI/MauiColor.cs
@@ -2,11 +2,19 @@
namespace Uno.Extensions.Maui;
+
+///
+/// This class represents a markup extension that converts a string representation of a color into a NativeMauiColor object.
+///
[MarkupExtensionReturnType(ReturnType = typeof(NativeMauiColor))]
public class MauiColor : MauiExtensionBase
{
+ ///
+ /// Gets or sets the string representation of the color value.
+ ///
public string Value { get; set; } = string.Empty;
+ ///
protected override void SetValue(View view, Type viewType, Type propertyType, BindableProperty property, string propertyName)
{
if (!string.IsNullOrEmpty(Value) || !NativeMauiColor.TryParse(Value, out var color))
diff --git a/src/Uno.Extensions.Maui.UI/MauiContent.cs b/src/Uno.Extensions.Maui.UI/MauiContent.cs
index d05a832aad..ce38007b5d 100644
--- a/src/Uno.Extensions.Maui.UI/MauiContent.cs
+++ b/src/Uno.Extensions.Maui.UI/MauiContent.cs
@@ -5,12 +5,18 @@
namespace Uno.Extensions.Maui;
+///
+/// ContentControl implementation that hosts a Maui view.
+///
[ContentProperty(Name = nameof(View))]
public partial class MauiContent : ContentControl
{
+ ///
+ /// The View property represents the that will be used as content.
+ ///
public static readonly DependencyProperty ViewProperty =
DependencyProperty.Register(nameof(View), typeof(View), typeof(MauiContent), new PropertyMetadata(null, OnViewChanged));
-
+
private static void OnViewChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs args)
{
if (args.NewValue is null || args.NewValue is not View view || dependencyObject is not MauiContent embeddedView)
@@ -18,7 +24,7 @@ private static void OnViewChanged(DependencyObject dependencyObject, DependencyP
return;
}
- if(embeddedView._host is not null)
+ if (embeddedView._host is not null)
{
view.Parent = embeddedView._host;
}
@@ -41,7 +47,7 @@ private static void OnViewChanged(DependencyObject dependencyObject, DependencyP
throw new MauiEmbeddingException(Properties.Resources.UnexpectedErrorConvertingMauiViewToNativeView, ex);
}
}
-
+
private static ILogger GetLogger() =>
MauiEmbedding.MauiContext.Services.GetRequiredService>();
@@ -49,12 +55,18 @@ private static ILogger GetLogger() =>
private readonly IMauiContext MauiContext;
+ ///
+ /// Initializes a new instance of the MauiContent class.
+ ///
public MauiContent()
{
MauiContext = MauiEmbedding.MauiContext;
Loading += OnLoading;
}
+ ///
+ /// Gets or sets the that will be used as content.
+ ///
public View View
{
get => (View)GetValue(ViewProperty);
@@ -66,11 +78,11 @@ private void OnLoading(FrameworkElement sender, object args)
Loading -= OnLoading;
DependencyObject? treeElement = this;
var resources = new ResourceDictionary();
- while(treeElement is not null)
+ while (treeElement is not null)
{
- if(treeElement is FrameworkElement element && element.Resources.Any())
+ if (treeElement is FrameworkElement element && element.Resources.Any())
{
- foreach((var key, var value) in element.Resources)
+ foreach ((var key, var value) in element.Resources)
{
if (resources.ContainsKey(key))
{
diff --git a/src/Uno.Extensions.Maui.UI/MauiEmbedding.cs b/src/Uno.Extensions.Maui.UI/MauiEmbedding.cs
index d1edcc1bad..9a326cc6ca 100644
--- a/src/Uno.Extensions.Maui.UI/MauiEmbedding.cs
+++ b/src/Uno.Extensions.Maui.UI/MauiEmbedding.cs
@@ -5,6 +5,9 @@
namespace Uno.Extensions.Maui;
+///
+/// Embedding support for Microsoft.Maui controls in Uno Platform app hosts.
+///
public static class MauiEmbedding
{
#if !NO_PLATFORM
@@ -21,6 +24,12 @@ public static class MauiEmbedding
: throw new MauiEmbeddingInitializationException();
#endif
+ ///
+ /// Registers Maui embedding in the Uno Platform app builder.
+ ///
+ /// The updated app builder.
+ /// The Uno app builder.
+ /// Optional lambda to configure the Maui app builder.
public static IApplicationBuilder UseMauiEmbedding(this IApplicationBuilder builder, Action? configure = null)
{
builder.App.UseMauiEmbedding(configure);
@@ -28,11 +37,21 @@ public static IApplicationBuilder UseMauiEmbedding(this IApplicationBuilder buil
}
#if NO_PLATFORM
+ ///
+ /// Not supported platform.
+ ///
+ /// The Uno app.
+ /// Optional lambda to configure the Maui app builder.
public static void UseMauiEmbedding(this Microsoft.UI.Xaml.Application app, Action? configure = null)
{
throw new PlatformNotSupportedException();
}
#else
+ ///
+ /// Registers Maui embedding with WinUI3 and WPF application builder.
+ ///
+ /// The Uno app.
+ /// Optional lambda to configure the Maui app builder.
public static void UseMauiEmbedding(this Microsoft.UI.Xaml.Application app, Action? configure = null)
{
var mauiAppBuilder = MauiApp.CreateBuilder()
diff --git a/src/Uno.Extensions.Maui.UI/MauiEmbeddingException.cs b/src/Uno.Extensions.Maui.UI/MauiEmbeddingException.cs
index f3907e56be..5b0a600147 100644
--- a/src/Uno.Extensions.Maui.UI/MauiEmbeddingException.cs
+++ b/src/Uno.Extensions.Maui.UI/MauiEmbeddingException.cs
@@ -1,12 +1,26 @@
namespace Uno.Extensions.Maui;
+///
+/// Represents an exception related to Maui embedding.
+///
public class MauiEmbeddingException : Exception
{
+ ///
+ /// Initializes a new instance of the class
+ /// with a specified error message.
+ ///
+ /// The message that describes the error.
internal MauiEmbeddingException(string message)
: base(message)
{
}
+ ///
+ /// Initializes a new instance of the class
+ /// with a specified error message and inner exception.
+ ///
+ /// The message that describes the error.
+ /// The exception that is the cause of the current exception.
internal MauiEmbeddingException(string message, Exception innerException)
: base(message, innerException)
{
diff --git a/src/Uno.Extensions.Maui.UI/MauiEmbeddingInitializationException.cs b/src/Uno.Extensions.Maui.UI/MauiEmbeddingInitializationException.cs
index da81efaee8..c92c14c84a 100644
--- a/src/Uno.Extensions.Maui.UI/MauiEmbeddingInitializationException.cs
+++ b/src/Uno.Extensions.Maui.UI/MauiEmbeddingInitializationException.cs
@@ -1,9 +1,18 @@
namespace Uno.Extensions.Maui;
+///
+/// Represents an that occurs during Maui embedding initialization.
+///
public sealed class MauiEmbeddingInitializationException : MauiEmbeddingException
{
+ ///
+ /// Gets the error message for the .
+ ///
public static string ErrorMessage => Properties.Resources.MauiEmbeddingInitializationExceptionMessage;
+ ///
+ /// Initializes a new instance of the class with the error message.
+ ///
internal MauiEmbeddingInitializationException()
: base(ErrorMessage)
{
diff --git a/src/Uno.Extensions.Maui.UI/MauiExtensionBase.cs b/src/Uno.Extensions.Maui.UI/MauiExtensionBase.cs
index 9d4064a12f..bcdfd54414 100644
--- a/src/Uno.Extensions.Maui.UI/MauiExtensionBase.cs
+++ b/src/Uno.Extensions.Maui.UI/MauiExtensionBase.cs
@@ -1,14 +1,24 @@
-using System.Reflection;
+using System.Numerics;
+using System.Reflection;
using Microsoft.Extensions.Logging;
using Microsoft.Maui.Controls;
+using Microsoft.UI.Xaml.Documents;
namespace Uno.Extensions.Maui;
+///
+/// Abstract class for extending in the context of .
+///
public abstract class MauiExtensionBase : MarkupExtension
{
private ILogger? _logger;
+
+ ///
+ /// Logger to log messages during runtime.
+ ///
protected ILogger Logger => _logger ??= GetLogger();
+ ///
protected sealed override object? ProvideValue(IXamlServiceProvider serviceProvider)
{
var provideValueTarget = (IProvideValueTarget)serviceProvider.GetService(typeof(IProvideValueTarget));
@@ -58,16 +68,29 @@ void OnParented(object? sender, EventArgs args)
return base.ProvideValue(serviceProvider);
}
-
+
private ILogger GetLogger()
{
var factory = MauiEmbedding.MauiContext.Services.GetRequiredService();
- var implemenatingType = GetType();
- return factory.CreateLogger(implemenatingType.Name);
+ var implementingType = GetType();
+ return factory.CreateLogger(implementingType.Name);
}
+ ///
+ /// Abstract method to set the value of a .
+ ///
+ /// The view to set the property value on.
+ /// The type of view to set the property value on.
+ /// The type of the property to set.
+ /// The to set.
+ /// The name of the property to set.
protected abstract void SetValue(View view, Type viewType, Type propertyType, BindableProperty property, string propertyName);
+ ///
+ /// Returns a default value of .
+ ///
+ /// Type of the target.
+ /// Default value of .
protected object? Default(Type type) =>
type.IsValueType ? Activator.CreateInstance(type) : null;
}
diff --git a/src/Uno.Extensions.Maui.UI/MauiResource.cs b/src/Uno.Extensions.Maui.UI/MauiResource.cs
index e9d3d4de9c..571fdbcb92 100644
--- a/src/Uno.Extensions.Maui.UI/MauiResource.cs
+++ b/src/Uno.Extensions.Maui.UI/MauiResource.cs
@@ -3,12 +3,26 @@
namespace Uno.Extensions.Maui;
+///
+/// A helper class used to set the value of a view's property by its key.
+///
[ContentProperty(Name = nameof(Key))]
[MarkupExtensionReturnType(ReturnType = typeof(object))]
public class MauiResource : MauiExtensionBase
{
+ ///
+ /// The key for the resource to be retrieved and set.
+ ///
public string Key { get; set; } = string.Empty;
+ ///
+ /// Sets the value of the view's property by the key.
+ ///
+ /// The whose property value will be set.
+ /// The type of the view.
+ /// The type of the property.
+ /// The property whose value will be set.
+ /// The name of the property.
protected override void SetValue(View view, Type viewType, Type propertyType, BindableProperty property, string propertyName)
{
if (string.IsNullOrEmpty(Key))
diff --git a/src/Uno.Extensions.Maui.UI/MauiThickness.cs b/src/Uno.Extensions.Maui.UI/MauiThickness.cs
index 329b6bc436..2eaa4308fe 100644
--- a/src/Uno.Extensions.Maui.UI/MauiThickness.cs
+++ b/src/Uno.Extensions.Maui.UI/MauiThickness.cs
@@ -1,10 +1,17 @@
namespace Uno.Extensions.Maui;
+///
+/// Provides a markup extension for creating a object from a string.
+///
[MarkupExtensionReturnType(ReturnType = typeof(Microsoft.Maui.Thickness))]
public class MauiThickness : MarkupExtension
{
+ ///
+ /// Gets or sets the string value to convert into a object.
+ ///
public string Value { get; set; } = string.Empty;
+ ///
protected override object ProvideValue()
{
if (string.IsNullOrEmpty(Value))