0

A few years ago I wrote a graphing application in Java. It stored edges and vertices in a QuadTree which I would loop through whenever I had to draw them.

Today I need to do something similar in WPF, however, I noticed that I have to add elements to a Children list inside a panel in order for it to draw. This is inefficient since now I am effectively storing two versions of the data. Removing elements is also costly compared to using quadtrees.

Are there any better ways of implementing this without having to use the Children List?

Dave
  • 7,283
  • 12
  • 55
  • 101
  • See if anything in this [SO question](http://stackoverflow.com/questions/2112034/drawing-3d-lines-in-wpf) will work for you – Mark Hall Jan 26 '12 at 03:48

1 Answers1

0

In WPF you usually do not use panels directly if you have a data source, instead you use some ItemsControl, bind its ItemsSource, set up the ItemsPanel to whatever panel you want to use, and create an ItemTemplate which defines how the items are to be displayed. (Canvas binding example)

This way of working with panels means you do not have manually take care of the Children collection, if your ItemsSource implements INCC it will stay in synch. I realize that this might be a bit difficult with your trees but maybe you can figure something out.

Community
  • 1
  • 1
H.B.
  • 166,899
  • 29
  • 327
  • 400