Skip to content

Highlight adorner not outlining everything #97

@dmrickey

Description

@dmrickey

Upgrading from 1.3 to current is changing the behavior to outline only the root element and not its children. I know in 1.3 it was broken so that it would highlight any space that tree item had taken up (as in it highlighted too much if the item was expanded then collapsed then highlighted).

Insight on if this is the expected behavior would be appreciated.

image

from DropTargetHighlightAdorner there is this. It looks like the problem is that rect is never empty so it never uses the height that I'm seeing on the screen.

    protected override void OnRender(DrawingContext drawingContext)
    {
        var visualTargetItem = this.DropInfo.VisualTargetItem;
        if (visualTargetItem != null) {
            var rect = Rect.Empty;

            var tvItem = visualTargetItem as TreeViewItem;
            if (tvItem != null && VisualTreeHelper.GetChildrenCount(tvItem) > 0) {
                var grid = VisualTreeHelper.GetChild(tvItem, 0) as Grid;
                if (grid != null) {
                    var descendant = VisualTreeHelper.GetDescendantBounds(tvItem);
                    rect = new Rect(tvItem.TranslatePoint(new Point(), this.AdornedElement), new Size(descendant.Width + 4, grid.RowDefinitions[0].ActualHeight));
                }
            }
            if (rect.IsEmpty) {
                rect = new Rect(visualTargetItem.TranslatePoint(new Point(), this.AdornedElement), VisualTreeHelper.GetDescendantBounds(visualTargetItem).Size);
            }
            drawingContext.DrawRoundedRectangle(null, new Pen(Brushes.Gray, 2), rect, 2, 2);
        }
    }

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions