我正在尝试将形状动态添加到网格中,我正在以这种方式创建和设置它:
Rectangle theRect = new Rectangle();
currentRect = theRect;
theRect.VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Top;
theRect.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Left;
theRect.Margin = new Thickness(oldPos.X,oldPos.Y,0,0);
theRect.StrokeThickness = brushWidht;
theRect.Stroke = new SolidColorBrush(brushColor);
theRect.Height = newPoint.Y - oldPos.Y;
theRect.Width = newPoint.X - oldPos.X;
theBoard.Children.Add(theRect);
但它粘在“theBoard”的角落,这是我放置它的网格。有人可以帮我吗?谢谢。