Browse Source
Merge pull request #2352 from AvaloniaUI/fixes/menu-item-command-property
fix menuitem command property.
pull/2353/head
danwalmsley
8 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
11 additions and
6 deletions
-
src/Avalonia.Controls/Button.cs
-
src/Avalonia.Controls/MenuItem.cs
|
|
|
@ -32,6 +32,8 @@ namespace Avalonia.Controls |
|
|
|
/// </summary>
|
|
|
|
public class Button : ContentControl |
|
|
|
{ |
|
|
|
private ICommand _command; |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Defines the <see cref="ClickMode"/> property.
|
|
|
|
/// </summary>
|
|
|
|
@ -69,8 +71,6 @@ namespace Avalonia.Controls |
|
|
|
public static readonly RoutedEvent<RoutedEventArgs> ClickEvent = |
|
|
|
RoutedEvent.Register<Button, RoutedEventArgs>(nameof(Click), RoutingStrategies.Bubble); |
|
|
|
|
|
|
|
private ICommand _command; |
|
|
|
|
|
|
|
public static readonly StyledProperty<bool> IsPressedProperty = |
|
|
|
AvaloniaProperty.Register<Button, bool>(nameof(IsPressed)); |
|
|
|
|
|
|
|
|
|
|
|
@ -20,11 +20,16 @@ namespace Avalonia.Controls |
|
|
|
/// </summary>
|
|
|
|
public class MenuItem : HeaderedSelectingItemsControl, IMenuItem, ISelectable |
|
|
|
{ |
|
|
|
private ICommand _command; |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Defines the <see cref="Command"/> property.
|
|
|
|
/// </summary>
|
|
|
|
public static readonly StyledProperty<ICommand> CommandProperty = |
|
|
|
AvaloniaProperty.Register<MenuItem, ICommand>(nameof(Command)); |
|
|
|
public static readonly DirectProperty<MenuItem, ICommand> CommandProperty = |
|
|
|
Button.CommandProperty.AddOwner<MenuItem>( |
|
|
|
menuItem => menuItem.Command, |
|
|
|
(menuItem, command) => menuItem.Command = command, |
|
|
|
enableDataValidation: true); |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Defines the <see cref="HotKey"/> property.
|
|
|
|
@ -159,8 +164,8 @@ namespace Avalonia.Controls |
|
|
|
/// </summary>
|
|
|
|
public ICommand Command |
|
|
|
{ |
|
|
|
get { return GetValue(CommandProperty); } |
|
|
|
set { SetValue(CommandProperty, value); } |
|
|
|
get { return _command; } |
|
|
|
set { SetAndRaise(CommandProperty, ref _command, value); } |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|