FocusItemByFullPath replaces selection

Grids for WPF Forum

Posted 4 years ago by Mike PB
Version: 19.1.0683
Platform: .NET 3.0 (Core)
Environment: Windows 10 (64-bit)
Avatar

Hello,

I have a problem with FocusItemByFullPath in TreeListBox. Our application manages selection of multiple items within the TreeListBox, and I want to set focus to the primary item within that selection. However if I use FocusItemByFullPath, the item is focussed but my selection is lost.

What I would expect is that FocusItemByFullPath simply changes the focus, and does not affect selection at all. Perhaps changes to the selection could be optionally included for convenience.

What do you think?

Thanks, Mike

PS This is on .Net Framework

[Modified 4 years ago]

Comments (2)

Answer - Posted 4 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Mike,

We have a way where you can prevent selection change notifications until a "batch" is complete.  This would allow you to effectively restore the prior selection before any selection change events go.

I tested with this kind of code where I selected three items and then executed this code that focused the second one.  All three items were selected at the end of the batch.

using (var batch = treeListBox.CreateSelectionBatch()) {
	var oldSelectedItems = treeListBox.SelectedItems.ToArray();
					
	treeListBox.FocusItem(treeListBox.SelectedItems[1]);
					
	foreach (TreeNodeModel item in oldSelectedItems)
		item.IsSelected = true;
}


Actipro Software Support

Posted 4 years ago by Mike PB
Avatar

Thanks - that seems to work around the problem, and could be a useful pattern for us elsewhere.

The latest build of this product (v24.1.2) was released 1 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.