It seems to me that addressing by the index is not very good, because the index says nothing about the intention of your code. Well, the index can change if you (or your follower in the project) add more controls. It is better to refer to the control by name.
By the way, I would have invented a more meaningful name than Image1
: in the middle of the night you wouldn’t say how Image1
differs from Image2
, but exactly Image_UserAvatar
from Image_CountryFlag
.
WPF has the ability to address controls in the window by name (for your case, it would be Form1.Image1
), and in this case, the caste is not needed - if there is such a possibility in Delphi, it is better to use it.