Skip to content

WPF Behaviors in ATF

Gary edited this page Mar 2, 2015 · 1 revision

Behaviors encapsulate capabilities into reusable modules, which can be attached to an element to give it additional capabilities.

ATF comes with a variety of behaviors you can use in your ATF applications. For an example of how one of these works in an application, see ContextMenuBehavior Class Operation. ContextMenuBehavior is used in the ATF Simple DOM Editor WPF Sample and is discussed in Behaviors.

ATF Behaviors Classes

ATF offers behaviors classes for a variety of application needs in the Sce.Atf.Wpf.Behaviors namespace. Here are some, many of which are used with ATF's WPF controls.

  • ActivateContextBehavior: Catch mouse down events and set ATF context registry active context to the current data context of the element.
  • AdaptableBehavior: Base adaptable behavior class. On attached, attempts to get IAdaptableControl interface on AssociatedObject and register itself. AssociatedObject is the object to which this behavior is attached.
  • AtfTreeViewBehavior: Behavior for TreeView that works alongside the TreeViewModel class to support multi-selection and "bring into view" abilities.
  • ButtonPopupBehavior: Displays the associated context menu on a button click.
  • CommandBehavior: Attached command behavior to hook routed events to ICommands in the view model.
  • ContextMenuBehavior: Behavior to provide hook for ATF context menu service. Right-clicking on the associated element queries all context menu providers for commands using the element's data context as the query target. If commands exist, a context menu is displayed. For details, see ContextMenuBehavior Class Operation.
  • ContextSensitiveToolBarBehavior: Toolbar behavior to display context sensitive information based on the current selection.
  • DialogButtonWorkaround: Attached property replacement for the standard Button.IsDefault to work around a bug in WPF.
  • DragAutoScrollBehavior: Behavior to auto scroll when dragging near edge of the element, such as a ListView. Can be attached to any framework element, but element must contain a scroll viewer in its visual tree for this behavior to function.
  • DragSourceBehavior<T>: Base drag source behavior.
  • DropTargetBehavior: Base drop target behavior.
  • EditableTextBlockAdorner: Adorner class that shows TextBox over the text block when edit mode is on.
  • EditableTextBlockBehavior: Editable text block behavior.
  • GridViewSortBehavior: GridView sort behavior.
  • InsertionAdorner: Adorner class for object being dragged over.
  • InstancingDropTargetBehavior: Drag and drop target that creates a new instance of the object on drop.
  • ItemsControlContextMenuBehavior: Behavior for ItemsControl that context menu is associated with. Used with ContextMenuBehavior.
  • ItemsControlDoubleClickBehavior: Selector double-click behavior that calls a bound ViewModel command when the user double clicks the Selector.
  • ItemsControlDragSourceBehavior: Items control drag source behavior that only deals with the single item under the mouse, not selection or multi-selection.
  • ItemsControlDropTargetBehavior: Drop target behavior for items control to accept drag and drop operations.
  • ItemsControlIndexedDropTargetBehavior: Items control indexed drop target behavior.
  • ItemsControlInsertionAdornerBehavior: Behavior to draw insertion adorners on items controls. For list based controls, this draws an insertion line while dragging items over the control. For TreeViews, it highlights the drop target TreeView item and optionally adds insertion lines.
  • LastHitAwareBehavior: Behavior for last item hit.
  • ListBoxScrollToEndBehavior: Behavior to auto scroll newly added list box items into view.
  • SelectionBehaviorBase: Base class for Selection behaviors. Can be used on Selectors or TreeViews.
  • SelectionContextDragSourceBehavior: Drag source behavior for elements with a selection context, as their data context drag and drop is initiated using current selection of items from the context.
  • SelectorLastHitAwareBehavior: Behavior for last item hit in Selector.
  • SelectorSelectFirstBehavior: Behavior for items such as ComboBoxes, which do not select the first item in the list when the ItemsSource changes and the control has previously been disabled.
  • SelectorSelectionBehavior: Behavior for selection in a Selector.
  • StyleBehaviors: Allow setting System.Windows.Interactivity.Behaviors with style setters.
  • TextBoxNumericBehavior: Behaviors for numeric entry in a TextBox, including minimum and maximum value, and whether to allow integer or decimal numbers.
  • TextBoxSelectAllBehavior: Select all text in a TextBox when it receives focus.
  • ThemeStyleBehavior: Attached property which allows a style that uses BasedOn="" to be re-based when the application theme is dynamically changed. Normally, if the BasedOn property of a style is set, once the application is loaded, changing the target style has no effect—the derived style remains based on the original style. This behavior works around this by cloning the style when a theme change occurs.
  • ToSourceSelectionBehavior: Bind the selection of items in a Selector to an ISelectionContext. Note that binding is only one way, that is, selection in the Selector is mirrored into the ISelectionContext, but not the other way.
  • TreeViewDragHoverExpandBehavior: Behavior to auto expand TreeView items when the mouse is hovered over them during a drag and drop operation.
  • TreeViewItemLabelEditBehavior: More complex version of standard double-click to edit label behavior. This behavior requires a single click on a focused item, but waits for a set time to check that no double-click occurs.
  • TwoWaySelectionBehavior: Add two way selection binding support between an ISelectionContext and a selector or multi-selector.

Topics in this Section

Clone this wiki locally