Skip to content

DevExpress-Examples/wpf-docklayoutmanager-load-an-external-window-or-usercontrol-into-a-documentpanel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WPF Dock Layout Manager - Load an External Window or UserControl into a DocumentPanel

You can define a Window, Page, or UserControl in external XAML files and load their contents into DocumentPanel objects.

This example loads an external Window and UserControl into DocumentPanels in three ways:

  1. Use the DocumentPanel.Content inherited property to load the content of MyWindow.xaml into a DocumentPanel at design time (in XAML). The Content property accepts an Uri object that is linked to a XAML file and defines a Window, Page, or UserControl.

    <dxdo:DocumentPanel x:Name="docPanel2" Caption="Panel 2" Content="{dxdo:RelativeUri UriString=CustomWindows\\MyWindow.xaml}"/>
  2. The DocumentPanel.Content property is set with a Uri object at runtime:

    docPanel1.Content = new Uri(@"CustomWindows\MyWindow1.xaml", UriKind.Relative);
  3. Call the DockLayoutManager.DockController's AddPanel method to create a new DocumentPanel object and load the contents of an external XAML file into the created panel.

    panel1 = dockLayoutManager1.DockController.AddDocumentPanel(documentGroup1,
    
        new Uri(@"CustomWindows\UserControl1.xaml", UriKind.Relative));
    
    panel1.Caption = "Document " + (ctr++).ToString();

In the example, the XAML file defines a UserControl object. The example's code uses the DocumentPanel's Control inherited property to access the loaded UserControl, and then invokes the UserControl's method:

//...

(panel1.Control as UserControl1).SetDataContext(imageInfo);

In the example, you can the Set DataContext for UserControl button to see this in action.

image

Files to Review

Documentation

More Examples

Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)

About

Loads an external Window and UserControl into DocumentPanels in XAML and in code.

Topics

Resources

License

Stars

Watchers

Forks