It is not enough to add, it is also necessary that it is drawn. By sabzh found an example

var rectangle = new Rectangle(); rectangle.Fill = Brushes.Red; rectangle.Width = 100; rectangle.Height = 100; Canvas.SetLeft(rectangle, 0); Canvas.SetTop(rectangle, 0); canvas1.Children.Add(rectangle); 

In the property of canvas1 itself, the element lies, but displays nothing on the screen.

Maybe the element properties in the XAML itself need to be adjusted? Or how else can you solve this problem?

  • one
    Where is the canvas itself? On the panel / popup, or what have you, it added? - Olter
  • This piece of code is classified. It costs a lot, so the question is only from the category - is it true that according to the help, the element is added to the canvas in the same way? - semenvx27
  • Author, ay! He asked and disappeared. Last visit was the 16th, lol. - Olter
  • In theory, it should work as it is written in the topic ... - allcreater

1 answer 1

you have a rectangle blending in with the background, just change its color