I have an original graph built in GraphArea
(WPF) and its subgraph as a list of vertices and edges. I want to highlight this subgraph on the original graph. But the method HighlightBehaviour.SetHighlighted(DependencyObject obj, bool value)
requires passing elements of the <DependencyObject>
type to it. Can you tell me how I can find them?
Asked
Active
Viewed 60 times
0

user1720736
- 1
- 3
1 Answers
0
Eureka!
var listE = new List<IGraphControl>();
listE.AddRange(GraphArea.EdgesList.Where(a => subGraph.Edges.Contains(a.Key)).Select(a => a.Value));
foreach (var edge in listE)
{
HighlightBehaviour.SetHighlighted((DependencyObject)edge, true);
}
var listV = new List<IGraphControl>();
listV.AddRange(GraphArea.VertexList.Where(a => subGraph.Vertices.Contains(a.Key)).Select(a => a.Value));
foreach (var vertx in listV)
{
HighlightBehaviour.SetHighlighted((DependencyObject)vertx, true);
}

user1720736
- 1
- 3
-
It's safer with `using System.Linq;`: `foreach (var edge in listE.OfType
()) { HighlightBehaviour.SetHighlighted(edge, true); }` – Clemens Jun 03 '22 at 10:02