WPF absolute positioning in InkCanvas

Posted by Nilu on Stack Overflow See other posts from Stack Overflow or by Nilu
Published on 2009-09-10T04:04:20Z Indexed on 2010/04/17 6:03 UTC
Read the original article Hit count: 599

Filed under:
|

Hi,

I'm trying to position a rectangle in an InkCanvas. I am using the following method. Unfortunately when I add the rectangle it gets displayed at (0,0). Although when I query to see the whether the left property is 0 I get a non zero values. Does anyone know why this might be?

Cheers,

Nilu

InkCanvas _parent = new InkCanvas();
private void AddDisplayRect(Color annoColour, Rect bounds)
    {
        Rectangle displayRect = new Rectangle();
        Canvas.SetTop(displayRect, bounds.Y);
        Canvas.SetLeft(displayRect, bounds.X);

        // check to see if the property is set
        Trace.WriteLine(Canvas.GetLeft(displayRect));
        displayRect.Width = bounds.Width;
        displayRect.Height = bounds.Height;
        displayRect.Stroke = new SolidColorBrush(annoColour);
        displayRect.StrokeThickness = 1;

        _parent.Children.Add(displayRect);            
    }

© Stack Overflow or respective owner

Related posts about wpf

Related posts about absolute-positioning