Skip to content

[Bug]: MewDock: TreeView (and other composite content) renders empty inside a tool pane; "visual is not connected to a window" on mouse move #192

Description

@rkttu

Summary

A TreeView placed inside a MewDock tool pane renders no rows (the pane is
blank). The same TreeView renders correctly as a plain Window's content.
A TextBlock renders fine both as the dock's CenterContent and as tool-pane
content, so only composite/virtualized controls appear to be affected.

In a variant where AddToolPane is called after the window is loaded,
moving the mouse over the (empty) tree pane throws:

System.InvalidOperationException: The visual is not connected to a window.
   at Aprillz.MewUI.MouseEventArgs.GetPosition(UIElement relativeTo)
   at Aprillz.MewUI.Controls.TreeView.OnMouseMove(MouseEventArgs e)
   at Aprillz.MewUI.Platform.Win32.Win32WindowBackend.HandleMouseMove(IntPtr lParam)
   at Aprillz.MewUI.Platform.Win32.Win32WindowBackend.ProcessMessage(UInt32 msg, IntPtr wParam, IntPtr lParam)
   at Aprillz.MewUI.Platform.Win32.Win32PlatformHost.WndProc(IntPtr hWnd, UInt32 msg, IntPtr wParam, IntPtr lParam)

Environment

  • Aprillz.MewUI 0.18.1, Aprillz.MewUI.MewDock 0.18.1 (all-in-one metapackage)
  • .NET SDK 10.0.301, target net10.0
  • Windows 11, Win32 platform host + Direct2D backend

Minimal reproduction

dotnet run repro.cs

#:sdk Microsoft.NET.Sdk
#:property OutputType=WinExe
#:property TargetFramework=net10.0
#:package Aprillz.MewUI@0.18.1
#:package Aprillz.MewUI.MewDock@0.18.1

using Aprillz.MewUI;
using Aprillz.MewUI.Controls;
using Aprillz.MewUI.MewDock;

if (OperatingSystem.IsWindows()) { Win32Platform.Register(); Direct2DBackend.Register(); }
ThemeManager.Default = ThemeVariant.Dark;

var root = new Node("Project (this row is expected to be visible)", new Node("Child.cs"));
var tree = new TreeView().ItemHeight(22).Indent(16);
tree.ItemsSource = TreeItemsView.Create(
    new[] { root }, n => n.Kids, n => n.Text, n => n.Text, n => n.Kids.Count > 0);

var manager = new DockingManager();
manager.CenterContent = new TextBlock { Text = "Centre (document area)", FontSize = 16 };
manager.AddToolPane("Tree Pane (BUG: empty)", tree, DockEdge.Left, "tree");
manager.AddToolPane("Text Pane (OK)",
    new TextBlock { Text = "A TextBlock in a tool pane renders.", FontSize = 13 },
    DockEdge.Bottom, "text");

Application.Run(new Window()
    .Title("MewDock repro: TreeView tool pane is empty")
    .Resizable(760, 500)
    .Content(manager));

sealed class Node
{
    public string Text { get; }
    public List<Node> Kids { get; } = new();
    public Node(string t, params Node[] k) { Text = t; Kids.AddRange(k); }
}

Expected

The left tool pane shows the tree ("Project …", expandable to "Child.cs"),
like the same TreeView does as a plain window's content.

Actual

The left tool pane is empty; the bottom TextBlock tool pane and the
centre TextBlock render normally.

Notes

  • Reproduced with both the direct AddToolPane(...) API and the
    WithContentFactory(...) + LoadLayout(json) path (as in samples/MewDock.Sample).
  • The identical TreeView renders fine in new Window().Content(new Border().Child(tree)).
  • A StackPanel of Button rows in a tool pane is also blank, so this looks
    like it affects container/virtualized content in tool panes generally, not
    TreeView specifically.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions