WPF absolute positioning in InkCanvas
I am trying to position a rectangle in a InkCanvas
. I am using the following method. Unfortunately, when I add a rectangle it displays in (0,0)
. Although, when I ask to see if the property has left 0
, I get non-null values. Does anyone know why this might be?
Greetings,
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);
}
+2
source to share