I have a Canvas with 2 children - an Image and a Rectangle.
I can get the height of the Rectangle as follows:
rectangle.Height
I can also get the height of the Rectangle like this:
inkCanvas1.Children[1].GetValue(Canvas.HeightProperty)
but when I try and get the Left (or Top) propert开发者_Go百科y of the Rectangle like this:
inkCanvas1.Children[1].GetValue(Canvas.LeftProperty)
it just returns zero.
I have also tried this:
Canvas.GetLeft(inkCanvas1.Children[1])
and that returns zero as well.
What I am certain of is that the Left and Top properties of the Rectangle are not zero (not least because I can see the Rectangle and move it around).
Solution anyone?
I thought I'd resuscitate this question because I am now having similar difficulties. If I add an image to my canvas and set the stretch property to uniform it also automatically centers the image. Now if I draw a rectangle on the image and descale it to get the ROI from the underlying bitmap, I get the wrong region. This is because the image is centered and my code is assuming the top left point of the image is 0,0. The difficulty is that I cannot get the actual top-left point of my image because the code above just returns 0,0. Neither can I seem to find a way to force the image to sit at the top-left position 0,0 in order that my code works. I find it frustrating that anything can sit at a position on a canvas but there is no way of retireving that position. Does anyone have any solutions to this?
精彩评论