I found the answer myself
the answer is that all names should be registered so the solution:
Grid myGrid = new Grid();
Image myImage = new Image();
myImage.Name = "myImage";
NameScope.SetNameScope(myGrid, new NameScope());
myGrid.RegisterName(myImage.Name, myImage);