|
|
@ -2,6 +2,7 @@ using System; |
|
|
using System.Windows.Input; |
|
|
using System.Windows.Input; |
|
|
using Avalonia.Input; |
|
|
using Avalonia.Input; |
|
|
using Avalonia.Media.Imaging; |
|
|
using Avalonia.Media.Imaging; |
|
|
|
|
|
using Avalonia.Metadata; |
|
|
using Avalonia.Utilities; |
|
|
using Avalonia.Utilities; |
|
|
|
|
|
|
|
|
namespace Avalonia.Controls |
|
|
namespace Avalonia.Controls |
|
|
@ -62,6 +63,7 @@ namespace Avalonia.Controls |
|
|
public static readonly DirectProperty<NativeMenuItem, NativeMenu> MenuProperty = |
|
|
public static readonly DirectProperty<NativeMenuItem, NativeMenu> MenuProperty = |
|
|
AvaloniaProperty.RegisterDirect<NativeMenuItem, NativeMenu>(nameof(Menu), o => o.Menu, (o, v) => o.Menu = v); |
|
|
AvaloniaProperty.RegisterDirect<NativeMenuItem, NativeMenu>(nameof(Menu), o => o.Menu, (o, v) => o.Menu = v); |
|
|
|
|
|
|
|
|
|
|
|
[Content] |
|
|
public NativeMenu Menu |
|
|
public NativeMenu Menu |
|
|
{ |
|
|
{ |
|
|
get => _menu; |
|
|
get => _menu; |
|
|
@ -151,7 +153,7 @@ namespace Avalonia.Controls |
|
|
IsEnabled = _command?.CanExecute(null) ?? true; |
|
|
IsEnabled = _command?.CanExecute(null) ?? true; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public bool HasClickHandlers => Clicked != null; |
|
|
public bool HasClickHandlers => Click != null; |
|
|
|
|
|
|
|
|
public ICommand Command |
|
|
public ICommand Command |
|
|
{ |
|
|
{ |
|
|
@ -182,11 +184,21 @@ namespace Avalonia.Controls |
|
|
set { SetValue(CommandParameterProperty, value); } |
|
|
set { SetValue(CommandParameterProperty, value); } |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public event EventHandler Clicked; |
|
|
/// <summary>
|
|
|
|
|
|
/// Occurs when a <see cref="NativeMenuItem"/> is clicked.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public event EventHandler Click; |
|
|
|
|
|
|
|
|
|
|
|
[Obsolete("Use Click event.")] |
|
|
|
|
|
public event EventHandler Clicked |
|
|
|
|
|
{ |
|
|
|
|
|
add => Click += value; |
|
|
|
|
|
remove => Click -= value; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
void INativeMenuItemExporterEventsImplBridge.RaiseClicked() |
|
|
void INativeMenuItemExporterEventsImplBridge.RaiseClicked() |
|
|
{ |
|
|
{ |
|
|
Clicked?.Invoke(this, new EventArgs()); |
|
|
Click?.Invoke(this, new EventArgs()); |
|
|
|
|
|
|
|
|
if (Command?.CanExecute(CommandParameter) == true) |
|
|
if (Command?.CanExecute(CommandParameter) == true) |
|
|
{ |
|
|
{ |
|
|
|