Ask a questionAsk a question
 

AnswerMDI Apps with WPF

Answers

  • Wednesday, March 15, 2006 6:13 PMLauren Lavoie - MS Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    I blogged about this a few months back (http://laurenlavoie.com/avalon/80):

    Why Doesn’t WPF Support MDI?

    Thursday, September 8th, 2005

    A few people have asked me why the WPF builds that we’ve released don’t include support for MDI. On one hand, I still want to do this for V1. On the other, I can’t imagine making people wait any longer before we ship this thing, on account of adding “just one more feature.”

    I do want to call out that the absence of MDI support in WPF does not at all imply that we don’t think this is important. Nor does it mean that we can’t add it in the next version if it doesn’t make it in for V1. There are a couple of factors influencing this decision:

    • Shipping. As I’m sure you know, software projects are always a game of making tradeoffs. Tradeoffs between features and other features, between features and bug fixes, between features and ship dates, and so on. MDI will be a huge feature if we implement it right (and implementing it right in this case means making it a true first-class citizen of WPF, so that it integrates well with styling, the property system, etc.), and at some point we had to decide between adding this new large feature and shipping the product.
    • Chocolate or vanilla? There are probably about 20 “flavors” of MDI. Word does MDI differently from Excel, Excel does MDI differently from Visual Studio, Visual Studio does MDI differently from Firefox (and yes, you might have caught on to my implication that I think tabbed browsing is just another flavor of MDI), Firefox does MDI differently from OneNote. In fact, a lot of apps use their own custom plumbing for MDI because the flavor provided by the API platform isn’t quite the right one. Before we go implement something as monolithic as MDI, we want to make sure that we choose the right flavor — or do it in a flexible enough way so that our developers can customize it to meet their needs. I don’t think any of us really knows the right way to do this yet — a big part of this needs to come from understanding the needs of customers who are actually building on WPF (that’s you, and hence the ask for feedback at the end of this post).

    So what if you want to build an MDI app now? Not all is lost, because there are ways around the limitation. Here are the two that I expect to be most common:

    1. Use Windows Forms interop. Nick Kramer describes how to do this, with a quick code sample, in this blog post.
    2. Bake it yourself. This is not as impossible as it sounds. In fact, a lot of apps out there do this today, because they want a different “flavor” of MDI than what comes out of the box with Win32/MFC/WinForms. Chris Anderson’s AvPad makes use of a custom implementation of a child window manager, and Chris claims it wasn’t hard to do. <g>

    If there is sufficient interest, I’d be very happy to write up a sample for current external bits showing #2 above — using Chris’s AvPad as a starting point, but really highlighting how to write the child window manager code. My only caveat is that this would happen after PDC.

    I’d also love feedback from those of you who are hurting by not having this support now. In particular — what’s your scenario, and what “flavor” of MDI are you looking to produce? Is it more like Excel, Word, Visual Studio, or something else entirely?

All Replies

  • Wednesday, March 15, 2006 6:13 PMLauren Lavoie - MS Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    I blogged about this a few months back (http://laurenlavoie.com/avalon/80):

    Why Doesn’t WPF Support MDI?

    Thursday, September 8th, 2005

    A few people have asked me why the WPF builds that we’ve released don’t include support for MDI. On one hand, I still want to do this for V1. On the other, I can’t imagine making people wait any longer before we ship this thing, on account of adding “just one more feature.”

    I do want to call out that the absence of MDI support in WPF does not at all imply that we don’t think this is important. Nor does it mean that we can’t add it in the next version if it doesn’t make it in for V1. There are a couple of factors influencing this decision:

    • Shipping. As I’m sure you know, software projects are always a game of making tradeoffs. Tradeoffs between features and other features, between features and bug fixes, between features and ship dates, and so on. MDI will be a huge feature if we implement it right (and implementing it right in this case means making it a true first-class citizen of WPF, so that it integrates well with styling, the property system, etc.), and at some point we had to decide between adding this new large feature and shipping the product.
    • Chocolate or vanilla? There are probably about 20 “flavors” of MDI. Word does MDI differently from Excel, Excel does MDI differently from Visual Studio, Visual Studio does MDI differently from Firefox (and yes, you might have caught on to my implication that I think tabbed browsing is just another flavor of MDI), Firefox does MDI differently from OneNote. In fact, a lot of apps use their own custom plumbing for MDI because the flavor provided by the API platform isn’t quite the right one. Before we go implement something as monolithic as MDI, we want to make sure that we choose the right flavor — or do it in a flexible enough way so that our developers can customize it to meet their needs. I don’t think any of us really knows the right way to do this yet — a big part of this needs to come from understanding the needs of customers who are actually building on WPF (that’s you, and hence the ask for feedback at the end of this post).

    So what if you want to build an MDI app now? Not all is lost, because there are ways around the limitation. Here are the two that I expect to be most common:

    1. Use Windows Forms interop. Nick Kramer describes how to do this, with a quick code sample, in this blog post.
    2. Bake it yourself. This is not as impossible as it sounds. In fact, a lot of apps out there do this today, because they want a different “flavor” of MDI than what comes out of the box with Win32/MFC/WinForms. Chris Anderson’s AvPad makes use of a custom implementation of a child window manager, and Chris claims it wasn’t hard to do. <g>

    If there is sufficient interest, I’d be very happy to write up a sample for current external bits showing #2 above — using Chris’s AvPad as a starting point, but really highlighting how to write the child window manager code. My only caveat is that this would happen after PDC.

    I’d also love feedback from those of you who are hurting by not having this support now. In particular — what’s your scenario, and what “flavor” of MDI are you looking to produce? Is it more like Excel, Word, Visual Studio, or something else entirely?

  • Wednesday, March 15, 2006 7:57 PMMichaelLattaModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    In addition to all the good points made by Lauren, I would add the following from a user point of view:

    1) Just as the list/grid features are turning out to be far more flexible in WPF than prior frameworks, the same should be true for window management in WPF in the long run.  Designing a good set of flexible primitives that work together to do MDI, user draggable areas like VS/Eclipse/Live.com/SharePoint, and can be used as building blocks for other layout issues will take time and experience with the platform.

    2) The main issue with MDI is the connection between the document and the display.  In some applications this is simply separate windows and requires little effort.  If you want tabbed documents as in VS or Firefox that again is not much work at all at the UI level.  The only form of MDI that requires much UI treatment is having user draggable/resizable child windows per document inside a large window.  Many people including parts of Microsoft believe this is not the best UI experience, and I would agree with that.  So I would not want them spending time on it.  It would not however be all that much work to do on current feature sets.  What would be very difficult to do would be provide native child window chrome.  For that the interop solution may be the best one.

    3) With WPF building your own child window chrome would not be much work, and it could reference the "document" object as its data context.  All that remains is drag/resize which is a simple mose event delegate, and support for tiling/tabbing which takes a bit more.  I would classify thsi level of effort as reasonable to have on a per-project basis in the v1 timeframe, and will drive the requirements for v2.  As the ATC posts are showing, there are many things that required a lot of code in the past that with WPF just are not that hard, and as a result do not require specific support in the framework.

  • Wednesday, March 15, 2006 10:42 PMLauren Lavoie - MS Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Great points, Michael. Thanks for commenting.
  • Thursday, March 16, 2006 3:33 AMmahalax Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Thank you Lauren & Michael, for the clarifications.
  • Friday, March 17, 2006 4:32 AMdzCepheus Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Lauren - I'm definately interested in seeing a sample MDI implementation using WPF, if you're still interested in building one. :)
  • Friday, March 17, 2006 6:52 PMLauren Lavoie - MS Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    This is still on my list of samples to write. I don't have an exact ETA though. :)
  • Friday, March 17, 2006 8:08 PMviliescuModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    As other have said, you can try to create your own MDI "framework". This is a small sample created by me:

    http://www.valil.com/winfx/portal.html


  • Saturday, December 27, 2008 6:49 PMchuck02323 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Got that example built yet?

  • Saturday, December 27, 2008 7:05 PMMike Cook - MSFT Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    There are third party solutions for this available as well.  A simple Live search gave this as the 3rd result:


    Mike Cook - Microsoft Developer