using System.Windows; namespace OpenSEMI.ClientBase.Command { public sealed class EventCommandTrigger : CommandTrigger { public static readonly DependencyProperty RoutedEventProperty = DependencyProperty.Register("RoutedEvent", typeof(RoutedEvent), typeof(EventCommandTrigger), new FrameworkPropertyMetadata(null)); public RoutedEvent RoutedEvent { get { return (RoutedEvent)GetValue(RoutedEventProperty); } set { SetValue(RoutedEventProperty, value); } } protected override Freezable CreateInstanceCore() { return new EventCommandTrigger(); } protected override void InitializeCore(FrameworkElement source) { source.AddHandler(RoutedEvent, new RoutedEventHandler(ExecuteCommand)); } private void ExecuteCommand(object sender, RoutedEventArgs args) { CommandParameter parameter = new EventCommandParameter(base.CustomParameter, RoutedEvent, args); ExecuteCommand(parameter); } } }