EventToCommand ClassDW.WPFToolkit Documentation
Brings the possibility to connect any event from a UI control with an ICommand.
Inheritance Hierarchy

SystemObject
  System.Windows.ThreadingDispatcherObject
    System.WindowsDependencyObject
      System.Windows.MediaVisual
        System.WindowsUIElement
          System.WindowsFrameworkElement
            DW.WPFToolkit.HelpersEventToCommand

Namespace: DW.WPFToolkit.Helpers
Assembly: DW.WPFToolkit (in DW.WPFToolkit.dll) Version: 5.6.0.0
Syntax

C#
public class EventToCommand : FrameworkElement, 
	IDisposable

The EventToCommand type exposes the following members.

Constructors

  NameDescription
Public methodEventToCommand
Initializes a new instance of the EventToCommand class
Top
Methods

  NameDescription
Public methodDispose
Disposes the CommandParameter to free it from its owner. Initialize(FrameworkElement) can be called afterwards again.
Public methodInitialize
Initializes EventToCommand object with the control which event should be catched.
Top
Fields

  NameDescription
Public fieldStatic memberCommandParameterProperty
Identifies the CommandParameter dependency property.
Public fieldStatic memberCommandProperty
Identifies the Command dependency property.
Public fieldStatic memberEventProperty
Identifies the Event dependency property.
Top
Properties

  NameDescription
Public propertyCommand
Gets or sets the command to be executed when the event (given by Event) got raised.
Public propertyCommandParameter
Gets or sets the command parameter to sent with the Event.
Public propertyEvent
Gets or sets the event name to listen to.
Top
Examples

XAML
<StackPanel>
    <Button Content="Demo Single">
        <Helpers:EventToCommandAdapter.EventToCommand>
            <Helpers:EventToCommand Event="MouseLeave" Command="{Binding MouseLeaveCommand}" />
        </Helpers:EventToCommandAdapter.EventToCommand>
    </Button>

    <Button Content="Demo Multiple">
        <Helpers:EventToCommandAdapter.EventsToCommands>
            <Helpers:EventToCommandCollection>
                <Helpers:EventToCommand Event="Click" Command="{Binding ClickCommand}" />
                <Helpers:EventToCommand Event="MouseEnter" Command="{Binding MouseEnterCommand}" />
                <Helpers:EventToCommand Event="MouseLeave" Command="{Binding MouseLeaveCommand}" />
            </Helpers:EventToCommandCollection>
        </Helpers:EventToCommandAdapter.EventsToCommands>
    </Button>
</StackPanel>
See Also

Reference