@ -12,13 +12,34 @@ namespace Avalonia.Controls
private readonly AvaloniaList < NativeMenuItemBase > _ items =
new AvaloniaList < NativeMenuItemBase > { ResetBehavior = ResetBehavior . Remove } ;
private NativeMenuItem _ parent ;
[Content]
public IList < NativeMenuItemBase > Items = > _ items ;
/// <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>
/// <remarks>
/// Do not update the menu in this event; use <see cref="NeedsUpdate"/>.
/// </remarks>
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 ( )
{
@ -27,10 +48,20 @@ namespace Avalonia.Controls
}
void INativeMenuExporterEventsImplBridge . RaiseNeedsUpdate ( )
{
NeedsUpdate ? . Invoke ( this , EventArgs . Empty ) ;
}
void INativeMenuExporterEventsImplBridge . RaiseOpening ( )
{
Opening ? . Invoke ( this , EventArgs . Empty ) ;
}
void INativeMenuExporterEventsImplBridge . RaiseClosed ( )
{
Closed ? . Invoke ( this , EventArgs . Empty ) ;
}
private void Validator ( NativeMenuItemBase obj )
{
if ( obj . Parent ! = null )