using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media;
namespace BuzzGUI.Common
{
///
/// Defines a Command Binding
/// This inherits from freezable so that it gets inheritance context for DataBinding to work
///
public class BehaviorBinding : Freezable
{
CommandBehaviorBinding behavior;
///
/// Stores the Command Behavior Binding
///
internal CommandBehaviorBinding Behavior
{
get
{
if (behavior == null)
behavior = new CommandBehaviorBinding();
return behavior;
}
}
DependencyObject owner;
///
/// Gets or sets the Owner of the binding
///
public DependencyObject Owner
{
get { return owner; }
set
{
owner = value;
ResetEventBinding();
}
}
#region Command
///
/// Command Dependency Property
///
public static readonly DependencyProperty CommandProperty =
DependencyProperty.Register("Command", typeof(ICommand), typeof(BehaviorBinding),
new FrameworkPropertyMetadata((ICommand)null,
new PropertyChangedCallback(OnCommandChanged)));
///
/// Gets or sets the Command property.
///
public ICommand Command
{
get { return (ICommand)GetValue(CommandProperty); }
set { SetValue(CommandProperty, value); }
}
///
/// Handles changes to the Command property.
///
private static void OnCommandChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
((BehaviorBinding)d).OnCommandChanged(e);
}
///
/// Provides derived classes an opportunity to handle changes to the Command property.
///
protected virtual void OnCommandChanged(DependencyPropertyChangedEventArgs e)
{
Behavior.Command = Command;
}
#endregion
#region Action
///
/// Action Dependency Property
///
public static readonly DependencyProperty ActionProperty =
DependencyProperty.Register("Action", typeof(Action