|
@@ -12,13 +12,34 @@ namespace Avalonia.Controls
|
|
|
private readonly AvaloniaList<NativeMenuItemBase> _items =
|
|
private readonly AvaloniaList<NativeMenuItemBase> _items =
|
|
|
new AvaloniaList<NativeMenuItemBase> { ResetBehavior = ResetBehavior.Remove };
|
|
new AvaloniaList<NativeMenuItemBase> { ResetBehavior = ResetBehavior.Remove };
|
|
|
private NativeMenuItem _parent;
|
|
private NativeMenuItem _parent;
|
|
|
|
|
+
|
|
|
[Content]
|
|
[Content]
|
|
|
public IList<NativeMenuItemBase> Items => _items;
|
|
public IList<NativeMenuItemBase> Items => _items;
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
|
- /// Raised when the user clicks the menu and before its opened. Use this event to update the menu dynamically.
|
|
|
|
|
|
|
+ /// Raised when the menu requests an update.
|
|
|
|
|
+ /// </summary>
|
|
|
|
|
+ /// <remarks>
|
|
|
|
|
+ /// Use this event to add, remove or modify menu items before a menu is
|
|
|
|
|
+ /// shown or a hotkey is pressed.
|
|
|
|
|
+ /// </remarks>
|
|
|
|
|
+ public event EventHandler<EventArgs> NeedsUpdate;
|
|
|
|
|
+
|
|
|
|
|
+ /// <summary>
|
|
|
|
|
+ /// Raised before the menu is opened.
|
|
|
/// </summary>
|
|
/// </summary>
|
|
|
|
|
+ /// <remarks>
|
|
|
|
|
+ /// Do not update the menu in this event; use <see cref="NeedsUpdate"/>.
|
|
|
|
|
+ /// </remarks>
|
|
|
public event EventHandler<EventArgs> Opening;
|
|
public event EventHandler<EventArgs> Opening;
|
|
|
|
|
+
|
|
|
|
|
+ /// <summary>
|
|
|
|
|
+ /// Raised after the menu is closed.
|
|
|
|
|
+ /// </summary>
|
|
|
|
|
+ /// <remarks>
|
|
|
|
|
+ /// Do not update the menu in this event; use <see cref="NeedsUpdate"/>.
|
|
|
|
|
+ /// </remarks>
|
|
|
|
|
+ public event EventHandler<EventArgs> Closed;
|
|
|
|
|
|
|
|
public NativeMenu()
|
|
public NativeMenu()
|
|
|
{
|
|
{
|
|
@@ -27,10 +48,20 @@ namespace Avalonia.Controls
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void INativeMenuExporterEventsImplBridge.RaiseNeedsUpdate()
|
|
void INativeMenuExporterEventsImplBridge.RaiseNeedsUpdate()
|
|
|
|
|
+ {
|
|
|
|
|
+ NeedsUpdate?.Invoke(this, EventArgs.Empty);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ void INativeMenuExporterEventsImplBridge.RaiseOpening()
|
|
|
{
|
|
{
|
|
|
Opening?.Invoke(this, EventArgs.Empty);
|
|
Opening?.Invoke(this, EventArgs.Empty);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ void INativeMenuExporterEventsImplBridge.RaiseClosed()
|
|
|
|
|
+ {
|
|
|
|
|
+ Closed?.Invoke(this, EventArgs.Empty);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private void Validator(NativeMenuItemBase obj)
|
|
private void Validator(NativeMenuItemBase obj)
|
|
|
{
|
|
{
|
|
|
if (obj.Parent != null)
|
|
if (obj.Parent != null)
|