0

I'm attempting to write an application which uses MDI, in the sense that I've got one big winsdow and a canvas area with a number of small children windows. These small windows can be resized, dragged and moved around within the canvas.

I've accomplished the above by using this library: http://wpfmdi.codeplex.com/

However, the library is full of bugs and is extremely restrictive (besides the fact that it is an abandoned project).

Thus, I was wondering what other options I have of employing MDI in WPF. I think it would be too much of a hassle to code a library similar to the one linked above - it basically handles the dragging and resizing of the small windows as well as makes sure that they cannot be dragged outside the edges of the canvas. I don't think this would be very easy to code myself.

Any ideas?

paparazzo
  • 44,497
  • 23
  • 105
  • 176
Dot NET
  • 4,891
  • 13
  • 55
  • 98
  • See this other SO question for alternatives http://stackoverflow.com/questions/5703954/alternative-to-mdi-in-wpf – Nasreddine Oct 21 '12 at 14:21
  • I don't want an alternative to MDI though - I know that MDI functionality is what I want. Nothing I can do about it anyway as it's part of specs. It has to be MDI. – Dot NET Oct 21 '12 at 14:23
  • @Dot NET I know it's been a while.. But curious to know if you found any good solution for implementing MDI in WPF. I tried the library mentioned in the question and share similar views - besides being buggy, it doesn't seem to work well when MDI content is a web browser control. – Chintan S Dec 11 '14 at 12:34
  • @ChintanS - Unfortunately I could not find a better library. It just looks like most people believe MDI is dead, so do not give it any importance. I disagree personally, and for my scenario, MDI was exactly what I needed, and nothing could have substituted. What I ended up doing was using this library and fixing issues if/when they arise. There are quite a few bugs, but luckily you have full and complete access to the code. Just be sure to load the library as a new project and you can change it as you like. – Dot NET Dec 12 '14 at 08:07
  • @DotNET - Hmm.. yes. That looks like the way to go for now. Thanks for your inputs :) – Chintan S Dec 12 '14 at 13:15

3 Answers3

0

I think you should use this, it is way cooler:

http://avalondock.codeplex.com/

It has tabs, resizable dockable panes, etc. Very similar to Visual Studio.

jonathanpeppers
  • 26,115
  • 21
  • 99
  • 182
  • I'm not sure if that's what I want though. All I need is to have multiple small windows in my main application - no more, no less. – Dot NET Oct 21 '12 at 14:23
  • Sounds like you should just code it yourself then, it is not that difficult to manage child windows. – jonathanpeppers Oct 21 '12 at 14:24
  • The problem is that I tried doing that originally and had such a hard time that I resorted to the plugin :/ – Dot NET Oct 21 '12 at 14:25
0

I've had another look at this MDI-library. I think I fixed the problem. You want the MdiChild to be Maximized as it does when you click it.

The problem is that if you set the WindowState of the MdiChild to Maximized in the constructor of the Main Window, you won't get the expected resizing. Therefore, you need to make sure that the Main Window is Loaded and then make sure the MdiChild is Loaded. If this is the case, you can programmatically set the WindowState of the MdiChild and get the expected behavior.

See the following sample code (check the full source code below) for the Loaded-events:

void Main_Loaded(object sender, RoutedEventArgs e)
{
    var mdiChild = new MdiChild
    {
        Title = "Window Using Code",
        Content = new ExampleControl(),
        Width = 500,
        Height = 450,
        Position = new Point(200, 30)
    };
    Container.Children.Add(mdiChild);
    mdiChild.Loaded +=new RoutedEventHandler(mdiChild_Loaded);
}

void mdiChild_Loaded(object sender, RoutedEventArgs e)
{
    if (sender is MdiChild)
    {
        var mdiChild = (sender as MdiChild);
        mdiChild.WindowState = WindowState.Maximized;
    }
}

Here's the source code to make it work. Let me know if this helps.

pdvries
  • 1,372
  • 2
  • 9
  • 18
  • Hi, I'm not sure if I understand comletely but I do not want the window to be maximised. What i want really is for it to have the same size as its contents – Dot NET Oct 21 '12 at 17:00
  • mdiChild.HorizontalContentAlignment = HorizontalAlignment.Stretch; mdiChild.VerticalContentAlignment = VerticalAlignment.Stretch; ? – pdvries Oct 21 '12 at 17:08
  • What about this: mdiChild.HorizontalAlignment = HorizontalAlignment.Stretch; mdiChild.HorizontalContentAlignment = HorizontalAlignment.Stretch; mdiChild.VerticalAlignment = VerticalAlignment.Stretch; mdiChild.HorizontalAlignment = HorizontalAlignment.Stretch; – pdvries Oct 21 '12 at 17:18
  • Still nothing - the window just refuses to stretch – Dot NET Oct 21 '12 at 17:22
  • I can't help you like this. There has to be something wrong with the alignment of your Controls or some properties not set right. I also added content to the MdiChild and it does resize. – pdvries Oct 21 '12 at 17:26
  • Don't worry about it :) Thanks anyway – Dot NET Oct 21 '12 at 17:27
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/18368/discussion-between-pjdevries-and-dot-net) – pdvries Oct 21 '12 at 17:37
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/18376/discussion-between-pjdevries-and-dot-net) – pdvries Oct 21 '12 at 20:12
0

New MDI option for WPF:

http://dragablz.net/2015/01/26/mdi-in-wpf-via-dragablz/

GitHub project: https://github.com/ButchersBoy/Dragablz

James Willock
  • 1,999
  • 14
  • 17