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?
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.