Building Mouse-enabled Controls

The MultiPoint Mouse WPF control derives from the existing WPF control class and implements additional interfaces to support MultiPoint Mouse events. This topic describes how to build a MultiPoint Mouse-enabled WPF control named “MultipointButton”.

Tip

The SDK provides a Visual Studio template that you can use to build MultiPoint Mouse-enabled controls.

The MultipointButton control derives from the WPF System.Windows.Controls.Button control class, and implements the IMultipointMouseEvents and IMultipointGenericDeviceEvents interfaces.

The IMultipointMouseEvents interface declares all the MultiPoint Mouse device-related events that you should implement for every MultiPoint Mouse-enabled control. The MultiPoint Mouse-enabled controls use the add and remove accessors to add and remove event handlers to MultiPoint Mouse device-related events. The MultipointButton class inherits from this interface to support device-related events:

public class MultipointButton : System.Windows.Controls.Button, IMultipointMouseEvents, IMultipointGenericDeviceEvents
{

}

MultipointButton implements the events defined in the interfaces:

public event RoutedEventHandler MultipointMouseLeftButtonDown 
{
     add
     {
         MultipointMouseEvents.AddMouseLeftButtonDownHandler(this, value);
     }
     remove 
     {
         MultipointMouseEvents.RemoveMouseLeftButtonDownHandler(this, value);
     }
} 

This code above Multipoint Mouse MouseLeftButtonDown events and provides add and remove accessors to register and un-register event handlers with this event. Other MultiPoint Mouse device-specific events are available in this class. The following is an example of the syntax for these events:

public event RoutedEventHandler MultipointXxxxx
{
     add
     {
         MultipointMouseEvents. AddXxxxxHandler(this, value);
     }
     remove 
     {
         MultipointMouseEvents. RemoveXxxxxHandler(this, value);
     }
}