Johan asked me about MDI support in Avalon. We don't plan to have a native Avalon implementation of MDI in version 1, mainly because MDI is so easy to do using Windows Forms and Windows Forms interop. I whipped together a quick demo of this, spending far too much time getting the Avalon content to look pretty before I realized there's no good way to post a picture on this blog (grumble grumble)...
First thing I did was fire up Visual Studio & start a new project I can do next Avalon-WinForms in (see earlier posts). I created a simple WinForms Form and set IsMdiContainer = true. Then I created a second WinForms Form to be the child window, and put one inside the other using:
Form f = new ChildForm(); f.MdiParent = mainForm; f.Visible = true;
So far, so good, but no Avalon -- so we bring in ElementHost. I whipped up a nifty Avalon menu & toolbar (called creatively "AvalonToolbar"), then added some code to my main window's constructor to put that Avalon toolbar inside and ElementHost, and put the ElementHost inside the window:
ElementHost host = new ElementHost(); host.Dock = DockStyle.Top; host.Height = 71;
// somewhat boneheaded way of getting Avalon content // into the ElementHost Page1 p = new Page1(); FrameworkElement root = p.root; p.Child = null; host.AddChild(root);
Probably would have been better to have the root of my AvalonToolbar.xaml be a Panel instead of a Page, which would have saved me the p.root/p.Child = null hassle, but for some reason I was feeling stubborn...
Finally, I did the same ElementHost thing with ChildForm, sticking a different block of Avalon content inside that Form. And voila! An MDI application with Avalon many/toolbar and child windows. Took me about fifteen minutes, the single greatest time sink was getting the documentation for the IsMdiContainer property (I didn't remember the MdiParent property, I guess it has been five years since I was on WinForms...).