TreeListView ItemExpanding has a bug

Grids for WPF Forum

The latest build of this product (v22.1.4) was released 2 months ago, which was before this thread was created.
Posted 14 days 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 14 days 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

Add Comment

Please log in to a validated account to post comments.