MultiSelectEventProcessor allow you to select multiple items by mouse down and drag.

Touch is enabled since build e33d1cef564d. Because the default drag is reserved for ScrollViewer's Panning, to use drag using touch, you have to Touch and Hold for one second before dragging.

To enable multiselect, add this processor to UIEventAdapter.Processors.
<bc:MultiSelectEventProcessor EnableMultiSelect="{Binding EnableMultiSelect}"  
                                    IsCheckboxEnabled="{Binding IsCheckBoxVisible, Mode=OneWay}"/>

Implement ISelectable in your Item's View Model, this is how you obtain whether an item is selecting or selected.

The process has been updated in 3.0.19, please see the source to understand how it works.

Adorner (AttachAdorner, UpdateAdorner, DetachAdorner)
DragAdorner is shown when dragging, it only provide visual effect. If it doesn't show please make sure your control have an AdornerLayer.

Finding highlighted items (FindSelectedItems)
MultiSelect use several ways to locate select items, the preferred way is your panel implements IChildInfo, which provide the coordinate for each item :
 public interface IChildInfo
      Rect GetChildRect(int itemIndex);

And if your view is GridView, MultiSelect will select all items between the first select (MouseDown) and last select (MouseUp) items.

The last method is to use VisualTreeHelper.HitTest(), which calls when MouseMove, find all and selected items on the visible area of your panel (ScrollViewer's Viewport), select the selected items, and unselect the (all - selected) items.

Selecting items
If your panel is not Virtualized, your items (ListViewItems) it selected/deselected using it's ListBoxItem.IsSelectedProperty property. If your panel is Virtualized, because your items are destroyed when not in the screen (ScrollViewer's Viewport), so it's not possible to set this property, in this case your ViewModel should implement ISelectable interface, and selection is using ISelectble.IsSelected property.
 public interface ISelectable
    bool IsSelected { get; set; }

AutoScroll (AutoScroll)
This allows the control to scroll automatically when drag beyond the ScrollViewer boundaries.

Last edited Oct 17, 2014 at 8:16 AM by lycj, version 8


No comments yet.