Building a Viewbox-like control

I found myself reading this post today as I wanted to build a Silverlight control which is a little like Viewbox in that it has ( let’s say ) a single lump of content that it wants to display and I was struggling to find the right base class for it.

Why? Because in WPF there are methods like AddLogicalChild on FrameworkElement whereas in Silverlight you don’t have this so you have to look for a control to sub-class which already has some notion of content ( like ContentControl perhaps 🙂 ).

Anyway, it’s an interesting read to see how Viewbox had to function a particular way when implemented by the Silverlight Toolkit team and ( if you look at the beta bits for Silverlight 3 ) you’ll find that it now works as you’d expect especially when you write XAML like;

                x:Name="xyz" />