I'm using GraphX for .NET and I'm trying to highlight a vertex when the user clicks on it.
I registered for the VertexSelected
event:
public class MyGraphArea : GraphArea<Node, Edge, MiniFlowGraph>
{
public MyGraphArea()
{
VertexSelected += VertexSelected_MarkVertex;
}
private void VertexSelected_MarkVertex(object sender,VertexSelectedEventArgs args)
{
HighlightBehaviour.SetHighlighted(args.VertexControl, true);
}
}
But nothing happened in the UI. So I tried to add multiple options:
To the constructor I added:
EnableVisualPropsApply = true;
HighlightBehaviour.SetIsHighlightEnabled(this, true);
SetVerticesHighlight(true, GraphControlType.VertexAndEdge);
I also registered to the Loaded
event and added this code:
foreach (var item in VertexList)
HighlightBehaviour.SetIsHighlightEnabled(item.Value, true);
Then I added the line SetVerticesHighlight(true, GraphControlType.VertexAndEdge)
to the VertexSelected
event, just for case.
But nothing happened.
I'm looking at the source code, and I can't find anything else.
I believe you just need to add the following lines of code:
I was playing around with the WindowsFormsProject example, and I added these lines just before the return statement of the method
Form1.GenerateWpfVisuals()
. I did not had to subscribe to any event. However, the standard behavior will highlight vertices and edges on mouse hover, not on mouse click.The default
Gold
color is used for the highlighting is defined intemplate.xaml
:...