Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
470
xamTreeMap - getting nodes within a bounding box
posted

I would like to be able to let the user select the nodes by drawing a lasso box around the nodes they are interested in. Is there a good way to do this?

To be more specific -- is there a way to get the nodes that are within a bounding box (say upper left and lower right corners of a rectangle).

Parents
No Data
Reply
  • 895
    Suggested Answer
    posted

    Hello,

    Attached is a WPF project, which performs the selection of Treemap nodes using a bounding box.

    Note that the selection will work in the yellow area and only leaf nodes are selected.

    You can alter the seleciton logic in the TreemapDragSelectionViewModel.cs file - TreemapNodeHitTestFilter method:

            /// <summary>
            /// Filters only the <see cref="TreemapNode"/> objects from the HitTest.
            /// </summary>
            /// <remarks>
            /// Note that this method will keep only the leaf nodes, but it can be modified
            /// to keep all nodes, which are under the selection region.
            /// </remarks>
            private HitTestFilterBehavior TreemapNodeHitTestFilter(DependencyObject potentialHitTestTarget)
            {
                HitTestFilterBehavior behavior = HitTestFilterBehavior.ContinueSkipSelf;
    
                if (potentialHitTestTarget is TreemapNode)
                {
                    TreemapNode node = (TreemapNode) potentialHitTestTarget;
                    if (node.Children.Count == 0)
                    {
                        _hitItems.Add(node);
                        behavior = HitTestFilterBehavior.ContinueSkipChildren;
                    }
                }
    
                return behavior;
            }
    

     

    Will this work for you?

Children
No Data