Skip to content

Commit

Permalink
Use SelectionModel in TreeView.
Browse files Browse the repository at this point in the history
  • Loading branch information
grokys committed Feb 7, 2020
1 parent 9b77a73 commit 24a0541
Show file tree
Hide file tree
Showing 4 changed files with 306 additions and 388 deletions.
14 changes: 11 additions & 3 deletions src/Avalonia.Controls/SelectionModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using Avalonia.Controls.Utils;

#nullable enable
Expand Down Expand Up @@ -117,6 +116,8 @@ public bool AutoSelect
}
}

public bool SelectOnlyLeafNodes { get; set; }

public IndexPath AnchorIndex
{
get
Expand Down Expand Up @@ -667,9 +668,16 @@ private void SelectRangeImpl(IndexPath start, IndexPath end, bool select)
winrtEnd,
info =>
{
if (info.Node.DataCount == 0)
if (SelectOnlyLeafNodes)
{
if (info.Node.DataCount == 0)
{
// Select only leaf nodes
info.ParentNode!.Select(info.Path.GetAt(info.Path.GetSize() - 1), select);
}
}
else
{
// Select only leaf nodes
info.ParentNode!.Select(info.Path.GetAt(info.Path.GetSize() - 1), select);
}
});
Expand Down
Loading

0 comments on commit 24a0541

Please sign in to comment.