I'm currently writing a component in C#/WPF to display chemical structures. It more or less follows MVVM principles (which are pretty new to me). Each atom and bond in the ViewModel is represented by a corresponding Shape in the view and connected via data binding. You can see it in operation below:
What I am concerned about is that each Atom is centered on a Point in a Canvas, but the overall View has no way of knowing precisely how big it is going to be. So, for instance, each CH3 group could potentially overspill the Canvas, as all the Canvas has got to go on when setting its bounds is the single Point that the atom shape is located at. This isn't a particular problem now, but could be an isue if large strings of characters were needed, for instance (CH3)3SiO or the suchlike.
So, what I'm wondering is whether there is a design pattern/stratagem/approach for bundling together all the objects in a View so overall properties can be extracted, for instance the full horizontal and vertical extents of a diagram. And then how would I go about binding those properties to my Canvas?
Please realise that I am an MVVM newbies and what might seem obvious and trite to you might be quite a revelation to me!