FocusItemByFullPath replaces selection

Grids for WPF Forum

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


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 5 years ago]

Comments (2)

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

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();
	foreach (TreeNodeModel item in oldSelectedItems)
		item.IsSelected = true;

Actipro Software Support

Posted 5 years ago by Mike PB

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 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.