Add CustomDocumentWindow Programmatically

Docking/MDI for WPF Forum

Posted 16 years ago by Henrique Duarte
Avatar
Hi guys,

I want to add a CustomDocumentWindow to a TabbedMdiContainer programmatically.
How can I do that?

Regards,

Henrique

[Modified at 01/31/2009 05:55 PM]

Comments (7)

Posted 16 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Henrique,

Just call CustomDocumentWindow.Activate(). That should add it.


Actipro Software Support

Posted 16 years ago by Henrique Duarte
Avatar
Hi,

I'm posting my code to help you to identify my problem.

private void menu_Click(object sender, RoutedEventArgs e)
{
    DocumentWindow wnd = null;

    switch ((e.Source as MenuItem).CommandParameter.ToString())
    {
        case "Contrato/Solicitacao/NovoContrato.aspx":
             wnd = new Contrato.Solicitacao.wNovoContrato();
             break;
    }

    wnd.Width = double.NaN;
    wnd.Height = double.NaN;

    wnd.Activate(true);
}
This is throwing the error:
This operation is invalid since the DockingWindow has not yet been registered with a DockSite.

To prevent this error, I'm adding the CustomDocumentWindow to TabbedMdiContainer before activating it.

Is there another way to do that?

Regards,

Henrique
Posted 16 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Ahh your custom DocumentWindow class must be calling the parameterless contructor of DocumentWindow. When making windows programmatically, you need to call the contructor that accepts a DockSite parameter. Change your code to that and it should work.


Actipro Software Support

Posted 16 years ago by Henrique Duarte
Avatar
Could you please provide one line of code?

Thanks,

Henrique
Posted 16 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
There are samples in our main Features demo like:
// Create the document
DocumentWindow documentWindow = new DocumentWindow(dockSite, name, title, 
    new BitmapImage(new Uri("/Resources/Images/TextDocument16.png", UriKind.Relative)), textBox);


Actipro Software Support

Posted 16 years ago by Henrique Duarte
Avatar
I know that, but wasn't what I needed.

Here is the code:

using ActiproSoftware.Windows.Controls.Docking;

namespace Sample
{
    public partial class CustomDocumentWindow : DocumentWindow
    {
        public CustomDocumentWindow(DockSite dockSite) : base(dockSite)
        {
            InitializeComponent();
        } 
    }
}
So, I can use this on menu:

private void menu_Click(object sender, RoutedEventArgs e)
{
    DocumentWindow wnd = null;

    switch ((e.Source as MenuItem).CommandParameter.ToString())
    {
        case "Sample/CustomDocumentWindow":
            wnd = new Sample.CustomDocumentWindow(dockSite);
            break;
    }

    wnd.Width = double.NaN;
    wnd.Height = double.NaN;
    wnd.Activate(true);
}
Thanks,

Henrique
Posted 16 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
What I was saying is call the same constructor I illustrated that has 5 parameters but the one you included in this snippet should work too. Are you saying that contructor call fixed it or you still have the issue?

If you still have the issue, please email a simple sample project over to our support address so we can look at it. Thanks.


Actipro Software Support

The latest build of this product (v24.1.3) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.