Menu

You can easily add the functionality of dragging an item around on a screen to an element by adding a MouseDragElementBehavior behavior.

The MouseDragElementBehavior behavior doesn't work for any controls that handle MouseClick events (Button, TextBox, and ListBox controls, for example). If you need the ability to drag a control of one of these types, make that control a child of a control that can be dragged (a border, for example). You can then apply the MouseDragElementBehavior behavior to the parent element.

To add a MouseDragElementBehavior

  1. In the Assets panel, click Behaviors, and then drag MouseDragElementBehavior onto the artboard and drop it onto the object that you have created. The Common Properties category appears in the Properties panel.

    NoteNote:

    The object to which the behavior is added provides the context within which the behavior operates.

  2. In the Common Properties category, select or clear the ConstrainToParentBounds property. When selected, the ConstrainToParentBounds property restricts the element from being dragged outside the boundaries specified by the parent layout container.

    In addition to ConstrainToParentBounds, two other advanced properties are exposed. These properties can be used (by using data binding, for example) to display the current X and Y coordinates of the element being dragged.

    MouseDragElementBehavior

To see a sample of this behavior, visit the Expression Community Gallery.


��Copyright � 2010 by Microsoft Corporation. All rights reserved.