Custom node view, creating a border around the node

Hi all,
I would like to have a border around my node.
Something like this.

I found different solutions but without getting what I am looking for.

    public class CustomModelView : INodeViewCustomization<HelloDyn>
    {
        public void CustomizeView(HelloDyn model, NodeView nodeView)
        {
            var brush = new SolidColorBrush(Color.FromArgb((int)byte.MaxValue, 231, 47, 135));

            // Result 1
            var rec = new Rectangle();
            rec.Fill = brush;
            nodeView.grid.Children.Add(rec);

            // Result 2
            nodeView.grid.Background = brush;

            // Result 3
            ((Border)nodeView.grid.FindName("customNodeBorder")).Background = brush;
            ((Border)nodeView.grid.FindName("customNodeBorder1")).BorderBrush = brush;
            ((Border)nodeView.grid.FindName("customNodeBorder1")).Background = brush;
            ((Border)nodeView.grid.FindName("customNodeBorder1")).BorderThickness = new Thickness(10);
            ((Rectangle)nodeView.grid.FindName("nodeBackground")).Fill = brush;
        }

        public void Dispose()
        {
        }
    }

Result 1
image

Result 2

Result 3
I don’t have any results, I think the changes should be done using some sort of action to update the graph view.

Any help is welcoming :slight_smile:
Thanks.

@Konrad_K_Sobon do you have any ideas?

Here is what I use in monocle for my custom node highlighter.


var rect = nv.FindName("nodeBorder") as System.Windows.Shapes.Rectangle;
rect.Stroke = new SolidColorBrush(Colors.LimeGreen);
rect.StrokeThickness = 2;
var doub = new DoubleCollection {6, 2};
rect.StrokeDashArray = doub;

Note: I changed it to dashes but you can just use the first bit.

2 Likes

Thanks @john_pierson this is exactly what I was looking for, and apparently, I was close but I was taking the wrong children! :sob:
This is great thanks!!!
image

1 Like