私は次のようにに描画しようとしRectangle
てCanvas
います:
System.Windows.Shapes.Rectangle rect;
rect = new System.Windows.Shapes.Rectangle();
rect.Stroke = new SolidColorBrush(Colors.Black);
rect.Fill = new SolidColorBrush(Colors.Black);
rect.Width=200;
rect.Height=200;
Canvas.SetLeft(rect,0);
Canvas.SetTop(rect,0);
front_canvas.Children.Add(rect);
このコードが長方形を描画しないのはなぜですか?
キャンバスは、関連するXAMLで次のように定義されます。
<Canvas Height="200" Width="200" Name="front_canvas" Grid.Row="1" Grid.Column="0">
</Canvas>
キャンバスはきれいに表示されます。レイアウトグリッドにギャップが残っているため、わかります。