none
Keeping a windows within the boundaries WPF view?

    Question

  • Hi,

    I'm migrating one Windows Forms 2.0 application to WPF.

    I've got one main view from where I am calling more views and putting them in a central frame keeping left and right expanders, one top menu, a toolbar and so on.

    Well, just trying to simulate the old MDI mechanism where you can keep all the windows inside the limits of your MDI; how can we do the same with WPF? When I call a Window, this windows goes his own way, beyond of the view limits.

    Thanks in advance,


    Primary platform is Windows 7 Ultimate 64 bit along with VS 2012/Sql2k8 for WPF and SilverLight stuff

    Wednesday, August 21, 2013 1:43 PM

Answers

  • If you're thinking in terms of Windows forms and MDI, its easy to think of pretty much everything - i.e. all visual objects - as being "windows", including "sub-windows" such as you get with MDI applications.

    In WPF however, the Window class is always a separate stand-alone window. I think what you may really need to so is use User Controls. A UserControl is a collection of other controls that you create in a very similar way to how you create a new window, except you can then use it like any other control, including placing it inside a Window.

    Have a look at this:

    http://www.codeproject.com/Articles/32825/How-to-Creating-a-WPF-User-Control-using-it-in-a-W

    UserControls can also be created and placed into a window dynamically, but by default will not have any kind of title bar or be movable (such a user-interface is considered pretty old-fashioned these days, I think, but if you want to keep functionality you will need to code that up yourself).

    • Edited by RJP1973 Wednesday, August 21, 2013 3:08 PM More explanation
    • Marked as answer by Enric Vives Monday, August 26, 2013 10:11 PM
    Wednesday, August 21, 2013 3:00 PM

All replies

  • If you're thinking in terms of Windows forms and MDI, its easy to think of pretty much everything - i.e. all visual objects - as being "windows", including "sub-windows" such as you get with MDI applications.

    In WPF however, the Window class is always a separate stand-alone window. I think what you may really need to so is use User Controls. A UserControl is a collection of other controls that you create in a very similar way to how you create a new window, except you can then use it like any other control, including placing it inside a Window.

    Have a look at this:

    http://www.codeproject.com/Articles/32825/How-to-Creating-a-WPF-User-Control-using-it-in-a-W

    UserControls can also be created and placed into a window dynamically, but by default will not have any kind of title bar or be movable (such a user-interface is considered pretty old-fashioned these days, I think, but if you want to keep functionality you will need to code that up yourself).

    • Edited by RJP1973 Wednesday, August 21, 2013 3:08 PM More explanation
    • Marked as answer by Enric Vives Monday, August 26, 2013 10:11 PM
    Wednesday, August 21, 2013 3:00 PM
  • So that you are proposing mel that creating a new usercontrol similar to one Windows Form I'll get the functionality

    I think it will be difficult create an UserControl like that.

    Primary platform is Windows 7 Ultimate 64 bit along with VS 2012/Sql2k8 for WPF and SilverLight stuff

    Sunday, August 25, 2013 8:28 AM