Skip to main content

DockLayoutManager.ItemsSource Property

Gets or sets a collection of objects providing information to generate and initialize layout items for the DockLayoutManager. This is a dependency property.

Namespace: DevExpress.Xpf.Docking

Assembly: DevExpress.Xpf.Docking.v23.2.dll

NuGet Package: DevExpress.Wpf.Docking

Declaration

public IEnumerable ItemsSource { get; set; }

Property Value

Type Description
IEnumerable

The source of objects to be visualized as layout items.

Remarks

The ItemsSource property supports the MVVM design pattern.

To populate the DockLayoutManager with existing panels, the ViewModel should implement the IMVVMDockingProperties interface. The TargetName property should return the name of the target layout group where DockLayoutManager places the created dock panel.

The following code sample populates DockLayoutManager with the ChildViews ViewModel collection:

public class MainViewModel : ViewModelBase {
        public ObservableCollection<PanelViewModel> Panels {
            get { return GetValue<ObservableCollection<PanelViewModel>>(); }
            set { SetValue(value); }
        }

        public MainViewModel() {
            Panels = new ObservableCollection<PanelViewModel>() {
                new PanelViewModel() { Caption = "One", Content = "A regular panel", TargetName = "documentGroup" },
                new PanelViewModel() { Caption = "Two", Content = "A regular panel", TargetName = "documentGroup" },
                new PanelViewModel() { Caption = "Three", Content = "A regular panel", TargetName = "documentGroup" },                
                new PanelViewModel() { Caption = "Five", Content = "A panel", TargetName = "layoutGroup" },
            };
        }
    }    

    public class PanelViewModel : ViewModelBase, IMVVMDockingProperties {
        public string Caption {
            get { return GetValue<string>(); }
            set { SetValue(value); }
        }
        public string Content {
            get { return GetValue<string>(); }
            set { SetValue(value); }
        }        
        public string TargetName {
            get { return GetValue<string>(); }
            set { SetValue(value); }
        }
    }
<UserControl ...
    xmlns:dxdo="http://schemas.devexpress.com/winfx/2008/xaml/docking">
    <UserControl.DataContext>
        <ViewModels:MainViewModel />
    </UserControl.DataContext>
    <Grid>
        <dxdo:DockLayoutManager ItemsSource="{Binding Panels}">
            <dxdo:DockLayoutManager.Resources>
                <Style x:Key="BaseStyle"
                       TargetType="dxdo:LayoutPanel">
                    <Setter Property="Caption" Value="{Binding Caption}" />
                    <Setter Property="ContentTemplate">
                        <Setter.Value>
                            <DataTemplate>
                                <TextBlock Text="{Binding Content}" />
                            </DataTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
                <Style BasedOn="{StaticResource BaseStyle}" TargetType="dxdo:LayoutPanel" />
                <Style BasedOn="{StaticResource BaseStyle}" TargetType="dxdo:DocumentPanel" />
            </dxdo:DockLayoutManager.Resources>
            <dxdo:LayoutGroup x:Name="root">
                <dxdo:LayoutGroup Name="layoutGroup" />
                <dxdo:DocumentGroup Name="documentGroup" />
            </dxdo:LayoutGroup>
        </dxdo:DockLayoutManager>
    </Grid>
</UserControl>

You can use the DockLayoutManager.ItemTemplate or DockLayoutManager.ItemTemplateSelector properties to customize the appearance of layout items that are stored in the ItemsSource collection.

The following code snippets (auto-collected from DevExpress Examples) contain references to the ItemsSource property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also