diff --git a/src/Avalonia.Controls/Button.cs b/src/Avalonia.Controls/Button.cs index 121087d262..16bb3c4377 100644 --- a/src/Avalonia.Controls/Button.cs +++ b/src/Avalonia.Controls/Button.cs @@ -79,6 +79,9 @@ namespace Avalonia.Controls public static readonly StyledProperty IsPressedProperty = AvaloniaProperty.Register(nameof(IsPressed)); + /// + /// Defines the property + /// public static readonly DirectProperty FlyoutProperty = AvaloniaProperty.RegisterDirect(nameof(Flyout), x => x.Flyout, (x, v) => x.Flyout = v); @@ -175,6 +178,9 @@ namespace Avalonia.Controls private set { SetValue(IsPressedProperty, value); } } + /// + /// Gets or sets the Flyout that should be shown with this button + /// public FlyoutBase Flyout { get => _flyout; diff --git a/src/Avalonia.Controls/Flyouts/Flyout.cs b/src/Avalonia.Controls/Flyouts/Flyout.cs index b1ca15bb4e..865e5a0fd1 100644 --- a/src/Avalonia.Controls/Flyouts/Flyout.cs +++ b/src/Avalonia.Controls/Flyouts/Flyout.cs @@ -1,10 +1,5 @@ -using System; -using System.Collections.Generic; -using System.Collections.Specialized; -using System.Text; -using Avalonia.Controls.Primitives; +using Avalonia.Controls.Primitives; using Avalonia.Metadata; -using Avalonia.Styling; #nullable enable @@ -12,13 +7,22 @@ namespace Avalonia.Controls { public class Flyout : FlyoutBase { + /// + /// Defines the property + /// public static readonly StyledProperty ContentProperty = AvaloniaProperty.Register(nameof(Content)); + /// + /// Gets the Classes collection to applied to the FlyoutPresenter this Flyout is hosting + /// public Classes? FlyoutPresenterClasses => _classes ??= new Classes(); private Classes? _classes; + /// + /// Gets or sets the content to display in this flyout + /// [Content] public object Content { diff --git a/src/Avalonia.Controls/Flyouts/FlyoutBase.cs b/src/Avalonia.Controls/Flyouts/FlyoutBase.cs index f51338565e..2ca637213f 100644 --- a/src/Avalonia.Controls/Flyouts/FlyoutBase.cs +++ b/src/Avalonia.Controls/Flyouts/FlyoutBase.cs @@ -15,20 +15,35 @@ namespace Avalonia.Controls.Primitives Control.ContextFlyoutProperty.Changed.Subscribe(OnContextFlyoutPropertyChanged); } + /// + /// Defines the property + /// private static readonly DirectProperty IsOpenProperty = AvaloniaProperty.RegisterDirect(nameof(IsOpen), x => x.IsOpen); + /// + /// Defines the property + /// public static readonly DirectProperty TargetProperty = AvaloniaProperty.RegisterDirect(nameof(Target), x => x.Target); + /// + /// Defines the property + /// public static readonly StyledProperty PlacementProperty = AvaloniaProperty.Register(nameof(Placement)); + /// + /// Defines the property + /// public static readonly DirectProperty ShowModeProperty = AvaloniaProperty.RegisterDirect(nameof(ShowMode), x => x.ShowMode, (x, v) => x.ShowMode = v); + /// + /// Defines the AttachedFlyout property + /// public static readonly AttachedProperty AttachedFlyoutProperty = AvaloniaProperty.RegisterAttached("AttachedFlyout", null); @@ -39,24 +54,36 @@ namespace Avalonia.Controls.Primitives Rect? enlargedPopupRect; IDisposable? transientDisposable; + /// + /// Gets whether this Flyout is currently Open + /// public bool IsOpen { get => _isOpen; private set => SetAndRaise(IsOpenProperty, ref _isOpen, value); } + /// + /// Gets or sets the desired placement + /// public FlyoutPlacementMode Placement { get => GetValue(PlacementProperty); set => SetValue(PlacementProperty, value); } + /// + /// Gets or sets the desired ShowMode + /// public FlyoutShowMode ShowMode { get => _showMode; set => SetAndRaise(ShowModeProperty, ref _showMode, value); } + /// + /// Gets the Target used for showing the Flyout + /// public Control? Target { get => _target; @@ -84,16 +111,29 @@ namespace Avalonia.Controls.Primitives flyout?.ShowAt(flyoutOwner); } + /// + /// Shows the Flyout at the given Control + /// + /// The control to show the Flyout at public void ShowAt(Control placementTarget) { ShowAtCore(placementTarget); } + /// + /// Shows the Flyout for the given control at the current pointer location, as in a ContextFlyout + /// + /// The target control + /// True to show at pointer public void ShowAt(Control placementTarget, bool showAtPointer) { ShowAtCore(placementTarget, showAtPointer); } + /// + /// Hides the Flyout + /// + /// Whether or not this closing action can be cancelled public void Hide(bool canCancel = true) { if (!IsOpen) @@ -253,6 +293,10 @@ namespace Avalonia.Controls.Primitives Closed?.Invoke(this, null); } + /// + /// Used to create the content the Flyout displays + /// + /// protected abstract Control CreatePresenter(); private void InitPopup() @@ -416,8 +460,7 @@ namespace Avalonia.Controls.Primitives c.ContextFlyout.ShowAt(c, true); } } - } - + } } } } diff --git a/src/Avalonia.Controls/Flyouts/FlyoutPlacementMode.cs b/src/Avalonia.Controls/Flyouts/FlyoutPlacementMode.cs index 15987daa50..0cde3c7b97 100644 --- a/src/Avalonia.Controls/Flyouts/FlyoutPlacementMode.cs +++ b/src/Avalonia.Controls/Flyouts/FlyoutPlacementMode.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Avalonia.Controls +namespace Avalonia.Controls { public enum FlyoutPlacementMode { diff --git a/src/Avalonia.Controls/Flyouts/FlyoutPresenter.cs b/src/Avalonia.Controls/Flyouts/FlyoutPresenter.cs index 80477d6969..5b753b20a2 100644 --- a/src/Avalonia.Controls/Flyouts/FlyoutPresenter.cs +++ b/src/Avalonia.Controls/Flyouts/FlyoutPresenter.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Avalonia.Controls +namespace Avalonia.Controls { public class FlyoutPresenter : ContentControl { diff --git a/src/Avalonia.Controls/Flyouts/MenuFlyout.cs b/src/Avalonia.Controls/Flyouts/MenuFlyout.cs index f147719281..54165cdf6e 100644 --- a/src/Avalonia.Controls/Flyouts/MenuFlyout.cs +++ b/src/Avalonia.Controls/Flyouts/MenuFlyout.cs @@ -1,11 +1,8 @@ using System.Collections; -using System.Collections.Specialized; using Avalonia.Collections; using Avalonia.Controls.Primitives; using Avalonia.Controls.Templates; -using Avalonia.Input; using Avalonia.Metadata; -using Avalonia.Styling; #nullable enable @@ -18,16 +15,25 @@ namespace Avalonia.Controls _items = new AvaloniaList(); } + /// + /// Defines the property + /// public static readonly DirectProperty ItemsProperty = ItemsControl.ItemsProperty.AddOwner(x => x.Items, (x, v) => x.Items = v); + /// + /// Defines the property + /// public static readonly DirectProperty ItemTemplateProperty = AvaloniaProperty.RegisterDirect(nameof(ItemTemplate), x => x.ItemTemplate, (x, v) => x.ItemTemplate = v); public Classes? FlyoutPresenterClasses => _classes ??= new Classes(); + /// + /// Gets or sets the items of the MenuFlyout + /// [Content] public IEnumerable Items { @@ -35,6 +41,9 @@ namespace Avalonia.Controls set => SetAndRaise(ItemsProperty, ref _items, value); } + /// + /// Gets or sets the template used for the items + /// public IDataTemplate? ItemTemplate { get => _itemTemplate;