开发者

Silverlight event delegates

I am dynamically building an org chart in Silverlight 2 by adding lots of Grid containers to a canvas. Each grid container represents a node within the chart. I am capturing click events for the nodes as follows:

gri开发者_如何学Pythond.MouseLeftButtonUp += new MouseButtonEventHandler(grid_MouseLeftButtonUp);

By design, each click event changes the look of the tree, so on capturing a click event I rebuild the entire org tree. This works ok for two or three clicks, but after that everything just hangs when I click a node (Grid). Each time I rebuild the tree I clear the base canvas using:

_canvasBase.Children.Clear();

I am wondering if I need to specifically clear all the event delegates before clearing all the canvas children? Or might something else be happening to cause the hang?


Yes you will be leak memory badly if you do not remove the event handlers.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜