TreeListView ItemExpanding has a bug

Grids for WPF Forum

Posted 1 year ago by Joey Lu
Version: 22.1.4
Platform: .NET 6.0
Environment: Windows 10 (64-bit)
Avatar
 private void OnTreeListViewExpanding(object sender, Windows.Controls.Grids.TreeListBoxItemExpansionEventArgs e)
    {
      if (e.Item is FruitTreeNodeModel fruit)
      {
        ExpandChildren(fruit);
      }
    }

    private void ExpandChildren(TreeNodeModel node)
    {
      node.IsExpanded = true;

      foreach (var item in node.Children)
      {
        ExpandChildren(item);
      }
    }

When the TreeListView is loaded for the first time and all its child nodes are collapsed, I use the above method to expand the child nodes. No matter clicking or double-clicking, it will cause repeated child nodes to appear on the UI, but in fact its number of child nodes is correct.  Is this a bug or is my usage wrong?

Comments (1)

Answer - Posted 1 year ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Joey,

When the expanding event fires, it's in the midst of doing various internal logic to sync its nodes up with the actual ItemsControl.  I believe that if you move that logic to the ItemExpanded event instead, it will work since that occurs after the internal logic executes.


Actipro Software Support

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.