Skip to content

Commit 087d431

Browse files
committed
Fixes snoopwpf#181 by getting logical children for Popup
1 parent 9e274dd commit 087d431

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

Snoop.Core/Data/Tree/PopupTreeItem.cs

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
namespace Snoop.Data.Tree
2+
{
3+
using System.Windows;
4+
using System.Windows.Controls.Primitives;
5+
6+
public class PopupTreeItem : DependencyObjectTreeItem
7+
{
8+
public PopupTreeItem(Popup target, TreeItem parent, TreeService treeService)
9+
: base(target, parent, treeService)
10+
{
11+
this.PopupTarget = target;
12+
}
13+
14+
public Popup PopupTarget { get; }
15+
16+
protected override void ReloadCore()
17+
{
18+
base.ReloadCore();
19+
20+
if (this.TreeService.TreeType == TreeType.Visual)
21+
{
22+
foreach (var child in LogicalTreeHelper.GetChildren(this.PopupTarget))
23+
{
24+
this.Children.Add(this.TreeService.Construct(child, this));
25+
}
26+
}
27+
}
28+
}
29+
}

Snoop.Core/Data/Tree/TreeService.cs

+5
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Windows;
66
using System.Windows.Automation;
77
using System.Windows.Automation.Peers;
8+
using System.Windows.Controls.Primitives;
89
using System.Windows.Media;
910
using System.Windows.Media.Media3D;
1011

@@ -50,6 +51,10 @@ public virtual TreeItem Construct(object target, TreeItem parent)
5051
treeItem = new WindowTreeItem(window, parent, this);
5152
break;
5253

54+
case Popup poup:
55+
treeItem = new PopupTreeItem(poup, parent, this);
56+
break;
57+
5358
case DependencyObject dependencyObject:
5459
treeItem = new DependencyObjectTreeItem(dependencyObject, parent, this);
5560
break;

0 commit comments

Comments
 (0)