Access StandardMdiWindowControl from DocumentWindow or DockSite

Docking/MDI for WPF Forum

Posted 5 years ago by Joe Gattone
Version: 11.2.0552
Avatar

Hello:
We have a MVVM application that displays UserControls in DocumentWindows hosted by a StandardMDIHost.

The DocumentWindow exposes some options for the StandardMdiWindowControl:WindowControl - Like allow view to support minimized / maximized.
However, it does not expose ResizeMode.

I would like to programatically access the ResizeMode property for a view after the view is created (could be done OnLoaded or OnNavigatedToFirstTime).
In debugger I can access the DocumentWindow. I can see the StandardMdiWindowControl in it, but it shows up as #8n and is locked.


Any suggestions ?

Thanks

Joe

Comments (2)

Posted 5 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Joe,

It's part of the template so to get it, you could get the first root visual child of the DocumentWindow while in that state and try-cast that to WindowControl, which is the base class of StandardMdiWindowControl.  WindowControl has a ResizeMode property.


Actipro Software Support

Posted 5 years ago by Joe Gattone
Avatar

That worked ! Thanks, very much appriciated !

Incase others are interested here's the code behind used.
Modify as needed if using in a Behavior or VM.

            DockSite docksite = this.Parent as DockSite;
            WindowControl wc = null;
           
            // The DockSite will have DocumentWindow's (1 for each open view)
            foreach (DocumentWindow dw in docksite.DocumentWindows)
            {                  
                if (dw.Content == this)
                {
                    // The DocumentWindow has a Visual Tree
                    // The first item (and should be only item) in the tree is
                    // a StandardMDIWindowControl (Actipro) , parent class is WindowControl (Actipro)
                    int i = VisualTreeHelper.GetChildrenCount(dw);
                    if(i == 1)
                    {
                        var child = VisualTreeHelper.GetChild(dw, 0);
                        // Cast the 1st item in the Visual Tree as a WindowControl 
                        wc = child as WindowControl;
                        wc.ResizeMode = ResizeMode.NoResize; 
                    }                  
                }
            }       
The latest build of this product (v2019.1 build 0681) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.