I use component DevExpress DockLayoutManager
According to the documentation on their website
http://documentation.devexpress.com/#WPF/DevExpressXpfDockingLayoutPanel_Uritopic
Control property "returns the root element of the Window / Page" - ie Grid.
Example is in their demo application: DockingDemo.Wpf DocumentGroups.xaml
And here is my code
DocumentGroup documentContainer = dockManager.GetItem("documentContainer") as DocumentGroup;
DocumentPanel panel = dockManager.DockController.AddDocumentPanel(documentContainer,new Uri("/WpfSample;component/MyWindows/Win1.xaml", UriKind.Relative));
panel.Caption = "SomeName";
MyWindow win = ((panel.Control as Grid).Parent as MyWindow);
win.DoInit(object Obj);
And when I call (panel.Control as Grid). Parent - I get a link to DockLayoutManager.
I do not quite understand. Window goes where? DockLayoutManager becomes Parent in the logical tree for the Grid of the Windows?
Tell me please - how to get Window, cast it to the required class and call its method?
ie how to make this code work
MyWindow win = ((panel.Control as Grid).Parent as MyWindow);
win.DoInit(object Obj);
According to the documentation, when the URI refers to a Window, the AddDocumentPanel method only loads the specified Window content. The Window object itself, its resources and event handlers are not loaded, and they cannot be accessed via the LayoutPanel.Control property.
You can use a UserControl object instead of the Window one. In this case, the UserControl itself will be loaded and you will be able to access the loaded UserControl via the LayoutPanel.Control property.