Browse Source

fix menuitem command property.

pull/2352/head
Dan Walmsley 8 years ago
parent
commit
e799543b94
  1. 4
      src/Avalonia.Controls/Button.cs
  2. 10
      src/Avalonia.Controls/MenuItem.cs

4
src/Avalonia.Controls/Button.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));

10
src/Avalonia.Controls/MenuItem.cs

@ -20,11 +20,13 @@ 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 +161,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>

Loading…
Cancel
Save