How can I “sleep” the control I need, namely Image, at a certain point of a certain parent through the code? In WF, this is done by adding a controller to the array of elements to the parent, and I didn’t find how to do the same in WPF

  • one
    You should not want this. In WPF, you do not construct a UI in an imperative way, but describe what you want to get, declaratively, in XAML. - VladD
  • @VladD Well, I need to make a lot of similar elements. Do you suggest doing this with presets in XAML? Or how? - Minebot
  • one
    Through ItemsControl easiest, for example. - VladD
  • 2
    Here is an example of creating one hundred hexagons: ru.stackoverflow.com/a/632894/10105 - VladD
  • 2
    @VladD Okay, look, thanks. Looks like I don’t understand the whole system in WPF - Minebot

1 answer 1

All WPF controls with a lot of children have the Children property.

usage example:

 var img = new Image(...); HouseCanvas.Children.Add(img); Canvas.SetLeft(img, 20); //позиционирование Canvas.SetTop(img, 20); //позиционирование 
  • 2
    Well, not so in all. In Border , for example, no. - VladD
  • You are welcome! [15 characters] - VladD