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);
Geometryas aDependencyProperty? You can attach to it outside. But it will need to be maintained in the correct and up-to-date state, of course. - VladD