What I want to do is find a way to know what the coordinates (or any property is) of the object (image) so I can use that to code where to put an ellipse on the image. I found something that talked about how to find the location of a texbox inside a stackpanel, but when I try to use the example, it throws an exeception “TargetInvocationException was unhandled”. Maybe I just dont understand how to do reference the different objects. I know the problem is in the first Dim Statement.
In Xaml:
<Window x:Class="MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Canvas x:Name="Can1">
<Image x:Name="Table1" Source="c:\images\table.jpg" Width="100" Height="100" Canvas.Left="75" Canvas.Top="75" />
<Ellipse Canvas.Left="100" Canvas.Top="100" Width="50" Height="50" Stroke="Green" StrokeThickness="4" />
</Canvas>
</Window>
And in the code:
Class MainWindow
Dim gt1 As GeneralTransform = Table1.TransformToAncestor(Can1)
Dim currentpoint As Point = gt1.Transform(New Point(0, 0))
End Class
So it should have been: