# .NET and More > WPF, WCF, WF >  MDI Substitute

## RobDog888

I'm starting in on re-writting our main desktop application from VB6 to .NET and want to use WPF. Now our legacy app is an MDI app and we need to maintain the flow/look as we have hundreds of agents that use it and re-training needs to be minimal to non-existant.

Anyone have any good solutions to maintain an "MDI" appearance / functionality? Its a large application so like with VB6's limit of 255 controls on a form (it has the control array thing to bypass it) and resource intensiveness should take some consideration here too.

Ive see using frames as one possible solution but I think it will be too heavy and would rather use separate "chjild" forms.

Thanks

----------


## chris128

Well first things first lets get you out of that winforms mind frame, we call them Windows in WPF, not Forms haha  :Big Grin:  just kidding (although that is true obviously)

What exactly are you wanting suggestions on then? How to actually implement an MDI like interface (as in the code for it) or just how to visually represent each MDI window etc?

----------


## RobDog888

Old habbits die hard  :LOL: 

Well MDI like interface but I dont want a heavy "window" if its only "simulating" MDI. It needs to be easily maintainable from a design aspect as it will be in place for a minimum of 5 years.

----------


## chris128

Oh right so you dont want want to use a Window for each MDI window/form in your app? Thats how you would use MDI in winforms isnt it, with a 'heavy' form for each MDI window instance.

Anywho, you can make some rather nice looking MDI-a-likes with WPF because of all the visual tricks WPF can pull off, for example its easy to create a thumbnail of all currently open windows and stick these in a selectable list (think Alt-Tab in Vista).
Here's a good example, although its kind of hard to see in this screenshot as its not on the window thats in focus: http://www.istartedsomething.com/wp-.../lawson_1l.jpg
See those thumbnail images at the top of the window that is in the background, that is an example of an MDI system implemented in WPF

----------


## RobDog888

Thanks Chris, that is a perfect example of the layout I need.  :Smilie: 

I meant I didnt want to use a single form/window that simulated an entire mdi app and have to repopulate the nav panel each time the "child" form was changed to a new mdi form.

So in that screen shot, what is its design like? A single window?

----------


## chris128

Not quite sure I understand the question but there would be the single 'parent' window yeah, and then however many different types of 'child' window you can have obviously. 
Thats not my application in the screenshot (as you probably guessed) but I assume the list of 'child' windows is just created by binding a listbox to a shared list that contains a reference to all of the open windows, then you would just apply your own data template to the listbox and it would automatically create a thumbnail etc for each window.

----------


## chris128

Dunno if this helps but I've put together a very rough no frills MDI style WPF app for you to see what Im talking about and have attached it to this post. It took me about 10 minutes to make so obviously there is a lot of things that need doing to make it usable but it demonstrates how you could go about doing this. As I said, it leaves a lot to be desired but what it does show you how to do is:
--- Bind a listbox to an "ObservableCollection" that contains the list of child windows, so that when we add a window to this list it automatically updates the listbox for us.
--- Apply a custom data template to the listbox so that it displays our child window thumbnails. Note that these are "live", so if you were to mouse over a button in a child window you would also see the mouse over effect in the thumbnail  :Smilie: 

Im sure that probably doesnt answer a lot of your questions though... but feel free to post any more that you have and I'll do my best to help out (im not exactly a WPF guru myself though!)  :Smilie:

----------


## RobDog888

Thanks Chris. This helps. I can redesign some of the apps architechure within a given limit and I think this is within that.

As an app overview I think creating a "Dashboard" as the parent form with each functional section as a separate window will work well for this first "module" of the application. I think if I break these apps out by function I can group the forms better and smaller/lighter.

I guess there is no real reason to try to maintain an actual MDI design. This should simplify things greatly. Thanks and yes I will post more WPF questions. We do have to drive up the traffic in WPF forum, right  :Big Grin:

----------


## chris128

haha exactly  :Big Grin:

----------


## RobDog888

I should be back on this next week and have some questions.

Need to fix 3 urgent bugs tomorrow and then see if qa "creates" anymore lol.

----------


## RobDog888

Deployment night so I get to do work on this again while we wait for tech ops to finish  :Smilie:

----------


## chris128

cool let us know how it goes  :Smilie:

----------


## RobDog888

Just getting a chance to work on it now. Its 2am and still in the ofice  :Frown: 

I'm gonna check out some videos and tuts first. Arg the pain of relearning

----------


## chris128

Yeah it is quite horrible not being able to do basic things in WPF that you could do in Winforms but it doesnt take that long to get used to it and realise how to do it  :Smilie:

----------


## ngreenwood6

Hey chris,

Can you walk me through how you got that mdi window to show in the listbox? I tried to duplicate it in c# but I must be missing something and am unable to find it. Any help is appreciated.

----------


## chris128

Which bit are you struggling with? All you should need to do is set the ItemsSource property of the listbox to a collection, in this case that collection is a list of the currently open windows.

----------


## ngreenwood6

Yeah that is what I did. Maybe I missed something. I will try to create a new project and see if maybe something happened to it.

----------


## ngreenwood6

I am getting this error:




> Window must be the root of the tree. Cannot add Window as a child of Visual.

----------

