Tell me how to act in such a situation ... There is a User Control, inside it lies a rectangle , WITHOUT a name . So how can I get a Geometry Rectangle 'but without a name, for example, from the main form of the program? I used to cope with:

Code in user control:

 public Geometry retgeometry() { return (myfavouriterectangle.RenderedGeometry); // myfavouriterectangle - это название того самого rectangle'а из которого мы должны получить Geometry } 

The code in the program itself:

 var controlgeometry = uiusercontrol.retgeometry(); 

And now you need to get rid of Name and now I remembered about a good thing like Binding .

UPD : @VladD that's what ...

  var g = tb.retgeometry(); g.Transform = (Transform)tb.TransformToAncestor(canvas); var m = (myui as uiusercontrol).retgeometry(); m.Transform = (Transform)(myui as uiusercontrol).TransformToAncestor(canvas); IntersectionDetail khg = m.FillContainsWithDetail(g); 
  • OK, let's go from implementation details to the meaning. What problem are you solving? What is the meaning of this geometry for the surrounding code? - VladD
  • @VladD theme updated - alex-rudenkiy
  • Still not clear. You do some calculations with her - I understood that. And for what, what's the point behind this? - VladD
  • @VladD Well, I just need to check whether 2 user controls are superimposed, and I do retgeometry to get the geometry of their rectangle backgrounds. You can certainly make everything easier, but it only works for me. - alex-rudenkiy
  • Okay, why wouldn't the usercontrol set Geometry as a DependencyProperty ? You can attach to it outside. But it will need to be maintained in the correct and up-to-date state, of course. - VladD

0