Add Window to DocumentContainer

Hi,

I saw the sample how to open CustomControls via code into a MD DocumentContainer within this thread:

https://www.syncfusion.com/forums/166896/wpf-documentcontainer-mdi (sample WpfApp28_a013ba-958063303)

I tried to open Windows in this way, but ever get an error message.

Is there a way to open Windows via c# code (not embedded within the XAML code) ?

Thanks and regards

Uwe


6 Replies

DR Durga Rajan Syncfusion Team January 26, 2022 12:15 PM UTC

Hi Uwe,


We have prepared sample to meet your requirement “Adding controls as a document to the DocumentContainer via code behind”, please check the sample and let us know whether it is helpful.


Code snippet :


ContentControl contentcontrol = new ContentControl();

            contentcontrol.Content = "Content of ContentControl";

            DocumentContainer.SetHeader(contentcontrol, "Document");

            documentContainer.Items.Add(contentcontrol);


https://help.syncfusion.com/wpf/tabbed-mdi-form/adding-and-removing-items-from-the-document-container-control?cs-save-lang=1&cs-lang=csharp#adding-items


If we have misunderstood your query, please share more details about your requirement.


Regards,

Durga


Attachment: DocumentContainer172283_a1c9a37a.zip


UP Uwe Porsch January 26, 2022 12:28 PM UTC

Thanks Durga,

it should that my request was not clear.

In the sample I found in https://www.syncfusion.com/forums/166896/wpf-documentcontainer-mdi (sample WpfApp28_a013ba-958063303)  customcontrols where added (UserControl which looked the same as a window).


            UserControl1 user = new UserControl1();

            documentContainer.Items.Add(user);

My question is, is it also possible to add a window direcly.

I added the orginal sample, where I tried to add the sales window and end in an exception.


Regards

Uwe


Attachment: WpfApp28_a013ba_7cb7574a.zip


SN Sudharsan Narayanan Syncfusion Team January 28, 2022 03:11 AM UTC

Hi Uwe,

We checked the shared sample that “Adding the Window to Document Container” that exception throws at the end. We have tried the same with the MS TabControl by adding another window to the control as child. It also throws the exception in MS TabControl. Please find the MSDN link for the same.

MSDN link: https://social.msdn.microsoft.com/Forums/vstudio/en-US/f8288536-c386-4d33-92d8-205434295ea1/window-must-be-the-root-of-the-tree-cannot-add-window-as-a-child-of-visual?forum=wpf&stoAI=10&f=255&MSPPError=-2147181130

Please let us know if you any concerns on this.

Regards,
Sudharsan



UP Uwe Porsch January 28, 2022 01:33 PM UTC

Hi Sudharsan,

thanks for the information. So I will create my Windows as UserControls and then it should work.

I will try it.

Regards

Uwe



SN Sudharsan Narayanan Syncfusion Team January 31, 2022 01:14 PM UTC

Hi Uwe,

 
Please try and get back to us if you need further assistance.

Regards,
Sudharsan



UP Uwe Porsch January 31, 2022 01:20 PM UTC

Hi Sudharsan,

it is okay for me. It is not what I expected. MDI should be better in Winforms (what I did before).

Thanks for your help.

Regards

Uwe


Loader.
Up arrow icon