ironmansoftware / powershell-universal

Issue tracker for PowerShell Universal
https://powershelluniversal.com
35 stars 2 forks source link

UDTreeView - Prevent Collapse #2252

Closed adamdriscoll closed 1 week ago

adamdriscoll commented 1 year ago

Summary of the new feature / enhancement

UDTreeView should have a parameter to prevent it from being collapsed.

Proposed technical implementation details (optional)

No response

abbottbd commented 1 year ago

just in case anyone stumbles on this and is trying to do the same thing - as the code is today in 3.8.9 you can work around this by using the following code in your 'onnodeclicked' for the UDTreeView: New-UDTreeview -node{[putyourownnodecodehere]} -Id 'treeView' -Expanded:$true -OnNodeClicked{ $ClickedNode = $EventData.ID Set-UDElement -ID 'treeView' -Properties @{expanded = @($EventData.ID)}
}

Basically you use the onnodeclicked code to force the node that was just clicked to be expanded, which overrides the default behavior which is to toggle the expanded property. As long as your tree isn't really big it shouldn't be too noticable that the tree is actually colapsing and then re-expanding.