Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 41 additions & 6 deletions src/Controls/src/Core/IControlsElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,44 @@

namespace Microsoft.Maui.Controls
{
internal interface IControlsElement : Maui.IElement
{
event EventHandler<HandlerChangingEventArgs>? HandlerChanging;
event EventHandler? HandlerChanged;
}
}
/// <summary>
/// Defines the core interface for elements that participate in handler-based rendering.
/// </summary>
/// <remarks>
/// This interface extends <see cref="Maui.IElement"/> to add handler lifecycle management specific to the Controls layer.
/// Handlers are the bridge between cross-platform Controls elements and platform-specific native views.
/// Implementations of this interface can respond to handler attachment, detachment, and replacement events,
/// enabling cleanup of platform-specific resources and re-initialization when handlers change.
/// </remarks>
public interface IControlsElement : Maui.IElement
{
/// <summary>
/// Occurs when the handler for this element is about to change, before the new handler is set.
/// </summary>
/// <remarks>
/// This event fires before <see cref="HandlerChanged"/> and provides access to both the old and new handler
/// through <see cref="HandlerChangingEventArgs"/>. This is the appropriate place to perform cleanup
/// operations on the old handler or platform view before they are replaced. The event allows subscribers
/// to react to handler changes before they take effect, enabling proper resource disposal and state transfer.
/// </remarks>
event EventHandler<HandlerChangingEventArgs>? HandlerChanging;

/// <summary>
/// Occurs after the handler for this element has been changed and the new handler is fully attached.
/// </summary>
/// <remarks>
/// This event fires after <see cref="HandlerChanging"/> when the handler transition is complete.
/// Subscribers can use this event to initialize resources, set up event handlers, or configure
/// the new platform-specific view. This is commonly used for accessing native platform views
/// after they have been created and attached to the element.
/// Common scenarios include:
/// <list type="bullet">
/// <item>Accessing the native platform view for customization</item>
/// <item>Setting up platform-specific event subscriptions</item>
/// <item>Initializing platform-dependent resources</item>
/// <item>Responding to handler recreation during hot reload scenarios</item>
/// </list>
/// </remarks>
event EventHandler? HandlerChanged;
}
}
2 changes: 1 addition & 1 deletion src/Controls/src/Core/IControlsView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace Microsoft.Maui.Controls
{
internal interface IControlsView : IControlsVisualElement
public interface IControlsView : IControlsVisualElement
{
}
}
53 changes: 46 additions & 7 deletions src/Controls/src/Core/IControlsVisualElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,49 @@

namespace Microsoft.Maui.Controls
{
internal interface IControlsVisualElement : IControlsElement, IView
{
event EventHandler? WindowChanged;
Window? Window { get; }
event EventHandler? PlatformContainerViewChanged;
}
}
/// <summary>
/// Defines a visual element that can be rendered and interact with platform-specific containers.
/// </summary>
/// <remarks>
/// This interface extends both <see cref="IControlsElement"/> for logical tree participation and
/// <see cref="IView"/> for visual rendering capabilities. It provides window and platform container
/// lifecycle management for visual elements that need to respond to changes in their hosting environment.
/// </remarks>
public interface IControlsVisualElement : IControlsElement, IView
{
/// <summary>
/// Occurs when the <see cref="Window"/> property value changes.
/// </summary>
/// <remarks>
/// This event is raised when the visual element is added to or removed from a window,
/// or when the element is moved between windows. Subscribers can use this event to perform
/// initialization or cleanup tasks related to window-specific resources.
/// </remarks>
event EventHandler? WindowChanged;

/// <summary>
/// Gets the window that contains this visual element, or <see langword="null"/> if the element
/// is not currently part of a window's visual tree.
/// </summary>
/// <value>
/// The <see cref="Window"/> instance that hosts this element, or <see langword="null"/>
/// if the element is detached from any window.
/// </value>
/// <remarks>
/// This property traverses up the visual tree to find the containing window. Elements that are not
/// yet added to a page or have been removed from the visual tree will return <see langword="null"/>.
/// </remarks>
Window? Window { get; }

/// <summary>
/// Occurs when the platform-specific container view that hosts this element changes.
/// </summary>
/// <remarks>
/// This event is raised when the native platform view (e.g., UIView on iOS, Android.Views.View on Android,
/// FrameworkElement on Windows) that contains this element is created, replaced, or destroyed.
/// This is particularly useful for scenarios requiring direct interaction with native views or
/// for responding to platform-specific lifecycle events.
/// </remarks>
event EventHandler? PlatformContainerViewChanged;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

namespace Microsoft.Maui.Controls.Platform
{
internal partial class AlertManager
public partial class AlertManager
{
private partial IAlertManagerSubscription CreateSubscription(IMauiContext mauiContext)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Microsoft.Maui.Controls.Platform
{
internal partial class AlertManager
public partial class AlertManager
{
private partial IAlertManagerSubscription CreateSubscription(IMauiContext mauiContext)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace Microsoft.Maui.Controls.Platform
{
internal partial class AlertManager
public partial class AlertManager
{
private partial IAlertManagerSubscription CreateSubscription(IMauiContext mauiContext)
{
Expand Down
7 changes: 5 additions & 2 deletions src/Controls/src/Core/Platform/AlertManager/AlertManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@

namespace Microsoft.Maui.Controls.Platform
{
internal partial class AlertManager
/// <summary>
/// Manages alert, action sheet, and prompt dialogs for a window.
/// </summary>
public partial class AlertManager
{
readonly Window _window;

Expand Down Expand Up @@ -65,7 +68,7 @@ public void RequestPageBusy(Page page, bool isBusy) =>

private partial IAlertManagerSubscription CreateSubscription(IMauiContext mauiContext);

internal interface IAlertManagerSubscription
public interface IAlertManagerSubscription
{
void OnActionSheetRequested(Page sender, ActionSheetArguments arguments);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace Microsoft.Maui.Controls.Platform
{
internal partial class AlertManager
public partial class AlertManager
{
private partial IAlertManagerSubscription CreateSubscription(IMauiContext mauiContext)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

namespace Microsoft.Maui.Controls.Platform
{
internal class GestureManager
public class GestureManager
{
readonly IControlsView _view;
object? _containerView;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

namespace Microsoft.Maui.Controls.Platform
{
class GesturePlatformManager : IDisposable
public class GesturePlatformManager : IDisposable
{
IViewHandler? _handler;
Lazy<ScaleGestureDetector> _scaleDetector;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Microsoft.Maui.Controls.Platform
{
class GesturePlatformManager : IDisposable
public class GesturePlatformManager : IDisposable
{
public GesturePlatformManager(IViewHandler handler)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

namespace Microsoft.Maui.Controls.Platform
{
class GesturePlatformManager : IDisposable
public class GesturePlatformManager : IDisposable
{
readonly IPlatformViewHandler _handler;
readonly NotifyCollectionChangedEventHandler _collectionChangedHandler;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

namespace Microsoft.Maui.Controls.Platform
{
class GesturePlatformManager : IDisposable
public class GesturePlatformManager : IDisposable
{
readonly NotifyCollectionChangedEventHandler _collectionChangedHandler;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

namespace Microsoft.Maui.Controls.Platform
{
internal partial class ModalNavigationManager
public partial class ModalNavigationManager
{
ViewGroup? _modalParentView;
AAnimation? _dismissAnimation;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace Microsoft.Maui.Controls.Platform
{
internal partial class ModalNavigationManager
public partial class ModalNavigationManager
{
Task<Page> PopModalPlatformAsync(bool animated)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Microsoft.Maui.Controls.Platform
{
internal partial class ModalNavigationManager
public partial class ModalNavigationManager
{
NavigationStack _modalStack => WindowMauiContext.GetModalStack();
IPageController CurrentPageController => CurrentPage!;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Microsoft.Maui.Controls.Platform
{
internal partial class ModalNavigationManager
public partial class ModalNavigationManager
{
WindowRootViewContainer Container =>
_window.NativeWindow.Content as WindowRootViewContainer ??
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace Microsoft.Maui.Controls.Platform
{
internal partial class ModalNavigationManager
public partial class ModalNavigationManager
{
Window _window;
public IReadOnlyList<Page> ModalStack => _modalPages.Pages;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

namespace Microsoft.Maui.Controls.Platform
{
internal partial class ModalNavigationManager
public partial class ModalNavigationManager
{
// We need to wait for the window to be activated the first time before
// we push any modal views.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,51 @@ Microsoft.Maui.Controls.ContentPage.SafeAreaEdges.get -> Microsoft.Maui.SafeArea
Microsoft.Maui.Controls.ContentPage.SafeAreaEdges.set -> void
Microsoft.Maui.Controls.ContentPresenter.CascadeInputTransparent.get -> bool
Microsoft.Maui.Controls.ContentPresenter.CascadeInputTransparent.set -> void
Microsoft.Maui.Controls.IControlsElement
Microsoft.Maui.Controls.IControlsElement.HandlerChanged -> System.EventHandler?
Microsoft.Maui.Controls.IControlsElement.HandlerChanging -> System.EventHandler<Microsoft.Maui.Controls.HandlerChangingEventArgs!>?
Microsoft.Maui.Controls.IControlsView
Microsoft.Maui.Controls.IControlsVisualElement
Microsoft.Maui.Controls.IControlsVisualElement.PlatformContainerViewChanged -> System.EventHandler?
Microsoft.Maui.Controls.IControlsVisualElement.Window.get -> Microsoft.Maui.Controls.Window?
Microsoft.Maui.Controls.IControlsVisualElement.WindowChanged -> System.EventHandler?
Microsoft.Maui.Controls.Platform.AlertManager
Microsoft.Maui.Controls.Platform.AlertManager.AlertManager(Microsoft.Maui.Controls.Window! window) -> void
Microsoft.Maui.Controls.Platform.AlertManager.IAlertManagerSubscription
Microsoft.Maui.Controls.Platform.AlertManager.IAlertManagerSubscription.OnActionSheetRequested(Microsoft.Maui.Controls.Page! sender, Microsoft.Maui.Controls.Internals.ActionSheetArguments! arguments) -> void
Microsoft.Maui.Controls.Platform.AlertManager.IAlertManagerSubscription.OnAlertRequested(Microsoft.Maui.Controls.Page! sender, Microsoft.Maui.Controls.Internals.AlertArguments! arguments) -> void
Microsoft.Maui.Controls.Platform.AlertManager.IAlertManagerSubscription.OnPageBusy(Microsoft.Maui.Controls.Page! sender, bool enabled) -> void
Microsoft.Maui.Controls.Platform.AlertManager.IAlertManagerSubscription.OnPromptRequested(Microsoft.Maui.Controls.Page! sender, Microsoft.Maui.Controls.Internals.PromptArguments! arguments) -> void
Microsoft.Maui.Controls.Platform.AlertManager.RequestActionSheet(Microsoft.Maui.Controls.Page! page, Microsoft.Maui.Controls.Internals.ActionSheetArguments! arguments) -> void
Microsoft.Maui.Controls.Platform.AlertManager.RequestAlert(Microsoft.Maui.Controls.Page! page, Microsoft.Maui.Controls.Internals.AlertArguments! arguments) -> void
Microsoft.Maui.Controls.Platform.AlertManager.RequestPageBusy(Microsoft.Maui.Controls.Page! page, bool isBusy) -> void
Microsoft.Maui.Controls.Platform.AlertManager.RequestPrompt(Microsoft.Maui.Controls.Page! page, Microsoft.Maui.Controls.Internals.PromptArguments! arguments) -> void
Microsoft.Maui.Controls.Platform.AlertManager.Subscribe() -> void
Microsoft.Maui.Controls.Platform.AlertManager.Subscription.get -> Microsoft.Maui.Controls.Platform.AlertManager.IAlertManagerSubscription?
Microsoft.Maui.Controls.Platform.AlertManager.Unsubscribe() -> void
Microsoft.Maui.Controls.Platform.AlertManager.Window.get -> Microsoft.Maui.Controls.Window!
Microsoft.Maui.Controls.Platform.GestureManager
Microsoft.Maui.Controls.Platform.GestureManager.GestureManager(Microsoft.Maui.Controls.IControlsView! view) -> void
Microsoft.Maui.Controls.Platform.GestureManager.GesturePlatformManager.get -> Microsoft.Maui.Controls.Platform.GesturePlatformManager?
Microsoft.Maui.Controls.Platform.GestureManager.IsConnected.get -> bool
Microsoft.Maui.Controls.Platform.GesturePlatformManager
Microsoft.Maui.Controls.Platform.GesturePlatformManager.Dispose() -> void
Microsoft.Maui.Controls.Platform.GesturePlatformManager.Dispose(bool disposing) -> void
Microsoft.Maui.Controls.Platform.GesturePlatformManager.GesturePlatformManager(Microsoft.Maui.IViewHandler! handler) -> void
Microsoft.Maui.Controls.Platform.GesturePlatformManager.OnTouchEvent(Android.Views.MotionEvent! e) -> bool
Microsoft.Maui.Controls.Platform.ModalNavigationManager
Microsoft.Maui.Controls.Platform.ModalNavigationManager.ModalNavigationManager(Microsoft.Maui.Controls.Window! window) -> void
Microsoft.Maui.Controls.Platform.ModalNavigationManager.ModalStack.get -> System.Collections.Generic.IReadOnlyList<Microsoft.Maui.Controls.Page!>!
Microsoft.Maui.Controls.Platform.ModalNavigationManager.PageAttachedHandler() -> void
Microsoft.Maui.Controls.Platform.ModalNavigationManager.PopModalAsync() -> System.Threading.Tasks.Task<Microsoft.Maui.Controls.Page?>!
Microsoft.Maui.Controls.Platform.ModalNavigationManager.PopModalAsync(bool animated) -> System.Threading.Tasks.Task<Microsoft.Maui.Controls.Page?>!
Microsoft.Maui.Controls.Platform.ModalNavigationManager.PushModalAsync(Microsoft.Maui.Controls.Page! modal) -> System.Threading.Tasks.Task!
Microsoft.Maui.Controls.Platform.ModalNavigationManager.PushModalAsync(Microsoft.Maui.Controls.Page! modal, bool animated) -> System.Threading.Tasks.Task!
Microsoft.Maui.Controls.Window.AlertManager.get -> Microsoft.Maui.Controls.Platform.AlertManager!
Microsoft.Maui.Controls.Window.ModalNavigationManager.get -> Microsoft.Maui.Controls.Platform.ModalNavigationManager!
virtual Microsoft.Maui.Controls.Platform.GesturePlatformManager.Control.get -> Android.Views.View?
virtual Microsoft.Maui.Controls.Platform.GesturePlatformManager.Control.set -> void
virtual Microsoft.Maui.Controls.Platform.GesturePlatformManager.Element.get -> Microsoft.Maui.Controls.VisualElement?
~Microsoft.Maui.Controls.ContentPresenter.Children.get -> System.Collections.Generic.IReadOnlyList<Microsoft.Maui.Controls.Element>
~Microsoft.Maui.Controls.ContentPresenter.LowerChild(Microsoft.Maui.Controls.View view) -> void
Microsoft.Maui.Controls.ContentPresenter.Padding.get -> Microsoft.Maui.Thickness
Expand Down
Loading
Loading