Working with FlexGrid > Grouping > C1FlexGridGroupPanel Implementation Notes |
We decided to implement the grouping UI feature as a separate assembly rather than adding it directly to the C1FlexGrid control for the following reasons:
The C1FlexGridGroupPanel is actually a Grid element with a TextBlock that shows the watermark message and a horizontal StackPanel that shows the groups available in the source ICollectionView.
The groups are represented by GroupMarker elements that can be clicked to sort or close the groups, or dragged to re-arrange the grouping order.
The C1FlexGridGroupPanel handles four types of dragging action:
All dragging actions are handled by a utility class called DragDropManager.
The first two types of dragging action are initiated by the GroupMarker class, which detects mouse dragging actions and calls the DragDropManager's DoDragDrop method with the marker as a parameter. The last two types of dragging action are initiated in response to the C1FlexGrid's DraggingColumn event.
When the DoDragDrop method is called, the DragDropManager displays a transparent element over the whole page, captures the mouse, and raises the Dragging event so the caller can update the drop location. When the user releases the mouse, the DragDropManager raises the Dropped event so the caller can finish the drag-drop action.
The implementation is very short and portable. The assembly is only about 25k and the code can be built against Silverlight or WPF without any conditional code blocks.