我正在尝试在InkCanvas
. 我正在使用以下方法。不幸的是,当我添加矩形时,它会显示在(0,0)
. 虽然当我查询左侧属性是否为0
非零值时。有谁知道这可能是为什么?
干杯,
尼禄
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);
}