Best Approach for a MDI Application in WPF?

Kishore Kumar picture Kishore Kumar · Apr 27, 2012 · Viewed 29.9k times · Source

I am developing a WPF Application for a Shop.

So i have a MainWindow and all the rest will be Child.

Which is the best thing to Use as Child Window.

  1. Window
  2. UserControl

Window will be normal, it will be top on the MainWindow and if its UserControl it will be in a Canvas of a MainWindow.

So can anyone suggest me which is best to use out of this two.

Answer

IAmTimCorey picture IAmTimCorey · Apr 27, 2012

I would recommend using UserControls for your child windows. This allows you to set up all of the "parent" controls on your main window and the children won't override them.

As a further suggestion, I would recommend looking into Caliburn Micro. That is a great framework for dealing with WPF windows and user controls.

To add a child UserControl to the parent window, I usually just add a ContentControl to my main form like so:

<ContentControl x:Name="ViewWindow" Margin="10" />

Just assign your child to that control and you will be fine.