MDI behavior in WPF?

I'm writing an industrial process control application to run on a PC, using .Net. The program monitors the progress of various parts being assembled by teams on the factory floor. There can be an arbitrary number of parts - 1,2,3,4,5, etc, and in the old VB6 version of the app each part gets its own window and the operators like to arrange them on the screen.

What I'm describing is a classic MDI interface but WPF doesn't support MDI. Other threads on SO have suggested the wpfmdi project on Codeplex, but that's listed as "abandoned" since last February ( http://wpfmdi.codeplex.com ) and avalondocks but those are docking tiles that don't look like they can be arbitrarily dragged and moved.

I don't know what to do. I didn't want to use WinForms because WPF/XAML provides cooler visuals and easier styling and because Microsoft seems to have abandoned WinForms. The current VB6 version of this product is 12 years old and I'd like to plan on a similar lifespan for the new one.

Thanks in advance!

Answers


I think you should consider using a payed-for third party component for MDI support. Nearly all of the standard vendors, DevExpress, Component One, Infragisitcs, Telerik provide an MDI solution.

Personally, I think MDI is still an entirely valid application UI structure!


I found the answer on another discussion forum (I can't remember which one or I'd give them credit). It turned out to be easier than I thought. If you hook the WM_MOVING message (I do it, below when the window is loaded) you can intercept moves before the window is moved and constrain the location of the window.

private void Window_Loaded(object sender, RoutedEventArgs e)
{
    WindowInteropHelper helper = new WindowInteropHelper(this);
    HwndSource.FromHwnd(helper.Handle).AddHook(HwndMessageHook);

    InitialWindowLocation = new Point(this.Left, this.Top);
}

// Grab the Win32 WM_MOVING message so we can intercept a move BEFORE 
// it happens and constrain the child window's location.

private IntPtr HwndMessageHook(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam, ref bool bHandled)
{
    switch (msg)
    {
        //   might also want to handle case WM_SIZING:
        case WM_MOVING:
            {
                WIN32Rectangle rectangle = (WIN32Rectangle)Marshal.PtrToStructure(lParam, typeof(WIN32Rectangle));

                if (rectangle.Top < 50)
                {
                    rectangle.Top = 50;
                    rectangle.Bottom = 50 + (int)this.Height;
                    bHandled = true;
                }

                if (rectangle.Left < 10)
                {
                    rectangle.Left = 10;
                    rectangle.Right = 10 + (int)this.Width;
                    bHandled = true;
                }

                if (rectangle.Bottom >800)
                {
                    rectangle.Bottom = 800;
                    rectangle.Top = 800 - (int)this.Height;
                    bHandled = true;
                }

                // do anything to handle Right case?
                if (bHandled)
                {
                    Marshal.StructureToPtr(rectangle, lParam, true);
                }
            }
            break;
    }
    return IntPtr.Zero;
}

The XAML header looks like this:

<Window x:Class="Mockup_9.Entity11"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:Mockup_9"
        ShowInTaskbar="False"
        Background="LightGoldenrodYellow"
        Loaded="Window_Loaded"
        Title="Mockup_part -" Height="540" Width="380" ResizeMode="NoResize"
        Icon="/Mockup_9;component/Images/refresh-icon1.jpg">

. . . etc.


Need Your Help

Jquery autocomplete - doesn't highlight items on hover and arrows don't work

javascript jquery css jquery-ui jquery-autocomplete

I've been wrestling with Jquery's autocomplete for a couple days now. I now have it properly displaying a JSON list of dictionaries from a page (/jsontest) using this:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.