Posted 30 June 2022, 3:11 pm EST
Is there a way to allow the user to click on the 1st item in the treeview, and then shift+click on a later item and have it select all items in between?
Forums Home / ComponentOne / WPF Edition
Posted by: dphillips on 30 June 2022, 3:11 pm EST
Posted 30 June 2022, 3:11 pm EST
Is there a way to allow the user to click on the 1st item in the treeview, and then shift+click on a later item and have it select all items in between?
Posted 1 July 2022, 3:32 am EST
Hi,
You need to handle ItemExpanded event to select 1st item on expanding a Parent node as:
        private void Item_Expanded(object sender, SourcedEventArgs e)
        {
            var node = e.Source as C1TreeViewItem;
            if(node != null)
            {
                if(node.HasItems)
                {
                    node.FirstNode.IsSelected = true;
                }
            }
        }
In order to achieve the requirement to select items using Shift+Click. You need to set SelectionMode=True. On expanding parent node the first item will be selected and then shift+click on a later item will select all items between them.
Please refer the attached sample for the same : C1TreeViewSample.zip
Best Regards,
Nitin