C#/WPF: LineGeometry with nested UI Elements

I am having problems using LineGeometry for drawing a path between two simple shapes nested in canvas elements.

Here is a quick demo I've put together to demonstrate the problem:

MainWindow.xaml : http://pastebin.ca/2010012

MainWindow.xaml.cs : http://pastebin.ca/2010013

(I thought pasting the code would make life easier for everyone as I am remarkably bad at trying to explain things :) )

In this demo I can succesfully draw a path between the rectangles nested in the parentCanvas, but when I try using the same method for the ellipses I have nested in seperate canvas elements (that are also nested within the parentCanvas) it doesn't seem to do anything.

The reason I am trying to accomplish this is for my actual application I am trying to visualise blocks (canvas elements) with multiple connection points (individual ellipses) so I need to be able to draw paths between these ellipses that are spread across different blocks. A graphical representation of this would be something like: http://img27.imageshack.us/img27/8255/blocksj0.png

Comments/suggestions appreciated.

Thanks, Hamza.


Well, I found a workaround to accomplish what I was initially trying to do. Instead of trying to find the child Shape element nested in Canvas elements, I simply calculate a set of coordinates from the position of the Shapes.

This bit of code should explain how I accomplish that:

lg.StartPoint = new Point((Canvas.GetLeft(canvasSrc) + canvasSrc.ActualWidth - 1), (Canvas.GetTop(canvasSrc) + Canvas.GetTop(rectangle5) + rectangle5.ActualHeight / 2));
lg.EndPoint = new Point((Canvas.GetLeft(canvasDest) + 1), (Canvas.GetTop(canvasSrc) + Canvas.GetTop(rectangle6) + rectangle6.ActualHeight / 2));

Posting this in case someone else finds it useful :)

Need Your Help

Backbone & Rails. Why do you set routes in backbone?

ruby-on-rails ruby-on-rails-3 backbone.js coffeescript

js and I want to create a rails app with backbone. The only problem is, I cant seem to figure out what goes in the backend and what goes in the frontend. The approach I am using is to use rails

Regex match and split string in C#

c# regex split pattern-matching match

I have some ASCII documents in the following format:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.