Example T211373
Visible to All Users

WPF Dock Layout Manager - Use Services That Implement the IDocumentManagerService Interface

Our MVVM Framework includes the following services that implement the IDocumentManagerService interface:

  1. DockingDocumentUIService
  2. FrameDocumentUIService
  3. TabbedDocumentUIService
  4. WindowedDocumentUIService
  5. TabbedWindowDocumentUIService

image

Files to Look At:

Documentation

More Examples

Does this example address your development requirements/objectives?

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

Example Code

DXDocumentUIServiceSample/MainWindow.xaml
XAML
<dx:ThemedWindow x:Class="DXDocumentUIServiceSample.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core" xmlns:dxdo="http://schemas.devexpress.com/winfx/2008/xaml/docking" xmlns:dxmvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm" xmlns:dxwui="http://schemas.devexpress.com/winfx/2008/xaml/windowsui" xmlns:dxwuin="http://schemas.devexpress.com/winfx/2008/xaml/windowsui/navigation" xmlns:View="clr-namespace:DXDocumentUIServiceSample.View" Title="DocumentUIServices" ShowIcon="False" Width="1415" Height="620"> <Grid> <dxdo:DockLayoutManager> <dxdo:LayoutGroup> <dxdo:TabbedGroup> <dxdo:LayoutPanel Caption="WindowedDocumentUIService"> <View:MainView> <dxmvvm:Interaction.Behaviors> <dx:WindowedDocumentUIService> <dx:WindowedDocumentUIService.WindowStyle> <Style TargetType="dx:ThemedWindow"> <Setter Property="Width" Value="800" /> <Setter Property="Height" Value="490" /> <Setter Property="ShowIcon" Value="False" /> </Style> </dx:WindowedDocumentUIService.WindowStyle> </dx:WindowedDocumentUIService> </dxmvvm:Interaction.Behaviors> </View:MainView> </dxdo:LayoutPanel> <dxdo:LayoutPanel Caption="TabbedDocumentUIService"> <dxdo:DockLayoutManager> <dxdo:LayoutGroup Orientation="Horizontal"> <dxdo:LayoutPanel Caption="Users"> <View:MainView> <dxmvvm:Interaction.Behaviors> <dxdo:TabbedDocumentUIService DocumentGroup="{Binding ElementName=documentGroup}" /> </dxmvvm:Interaction.Behaviors> </View:MainView> </dxdo:LayoutPanel> <dxdo:DocumentGroup x:Name="documentGroup" Caption="Documents" ItemHeight="*" /> </dxdo:LayoutGroup> </dxdo:DockLayoutManager> </dxdo:LayoutPanel> <dxdo:LayoutPanel Caption="DockingDocumentUIService"> <dxdo:DockLayoutManager> <dxdo:LayoutGroup Orientation="Horizontal"> <dxdo:LayoutPanel Caption="Users"> <View:MainView> <dxmvvm:Interaction.Behaviors> <dxdo:DockingDocumentUIService LayoutGroup="{Binding ElementName=layoutGroup}" /> </dxmvvm:Interaction.Behaviors> </View:MainView> </dxdo:LayoutPanel> <dxdo:LayoutGroup x:Name="layoutGroup" Caption="Panels" DestroyOnClosingChildren="False" ItemHeight="*" /> </dxdo:LayoutGroup> </dxdo:DockLayoutManager> </dxdo:LayoutPanel> <dxdo:LayoutPanel Caption="FrameDocumentUIService"> <dxwui:NavigationFrame AnimationType="SlideHorizontal"> <dxwui:NavigationFrame.Source> <View:MainView> <dxmvvm:Interaction.Behaviors> <dxwuin:FrameDocumentUIService /> </dxmvvm:Interaction.Behaviors> </View:MainView> </dxwui:NavigationFrame.Source> </dxwui:NavigationFrame> </dxdo:LayoutPanel> </dxdo:TabbedGroup> </dxdo:LayoutGroup> </dxdo:DockLayoutManager> </Grid> </dx:ThemedWindow>
DXDocumentUIServiceSample/View/DetailedView.xaml
XAML
<UserControl x:Class="DXDocumentUIServiceSample.View.DetailedView" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:dxc="http://schemas.devexpress.com/winfx/2008/xaml/charts" xmlns:common="clr-namespace:DXDocumentUIServiceSample.Common"> <Grid> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> <RowDefinition /> </Grid.RowDefinitions> <GroupBox Grid.Row="0" Header="User Info"> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition /> <ColumnDefinition /> </Grid.ColumnDefinitions> <StackPanel Grid.Column="0"> <TextBlock Text="{Binding Path=ID, Converter={common:StringAggregationConverter}, ConverterParameter=ID}" /> <TextBlock Text="{Binding NickName, Converter={common:StringAggregationConverter}, ConverterParameter=Nick}" /> </StackPanel> <StackPanel Grid.Column="1"> <TextBlock Text="{Binding Registration, Converter={common:StringAggregationConverter}, ConverterParameter=Registration}" /> <TextBlock Text="{Binding Rating, Converter={common:StringAggregationConverter}, ConverterParameter=Rating}" /> </StackPanel> </Grid> </GroupBox> <GroupBox Grid.Row="1" Header="Activity By User"> <dxc:ChartControl> <dxc:XYDiagram2D> <dxc:SplineAreaSeries2D ArgumentDataMember="Month" DataSource="{Binding GlobalUserActivity}" DisplayName="Global Activity" LabelsVisibility="True" Transparency="0.5" ValueDataMember="Count" /> <dxc:SplineAreaSeries2D ArgumentDataMember="Month" DataSource="{Binding LocalUserActivity}" DisplayName="Local Activity" LabelsVisibility="True" Transparency="0.5" ValueDataMember="Count" /> </dxc:XYDiagram2D> </dxc:ChartControl> </GroupBox> </Grid> </UserControl>
DXDocumentUIServiceSample/View/MainView.xaml
XAML
<UserControl x:Class="DXDocumentUIServiceSample.View.MainView" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid" xmlns:vm="clr-namespace:DXDocumentUIServiceSample.ViewModel"> <UserControl.DataContext> <vm:MainViewModel /> </UserControl.DataContext> <Grid> <Grid.RowDefinitions> <RowDefinition /> <RowDefinition Height="Auto" /> </Grid.RowDefinitions> <GroupBox Header="Users"> <dxg:GridControl Name="grid" ItemsSource="{Binding Users}"> <dxg:GridControl.Columns> <dxg:GridColumn FieldName="NickName" /> <dxg:GridColumn FieldName="Registration" /> <dxg:GridColumn FieldName="Rating" /> </dxg:GridControl.Columns> <dxg:GridControl.View> <dxg:TableView AllowEditing="False" AutoWidth="True" FadeSelectionOnLostFocus="False" VerticalScrollbarVisibility="Auto" RowDoubleClickCommand="{Binding DoubleClickCommand}" /> </dxg:GridControl.View> </dxg:GridControl> </GroupBox> <GroupBox Grid.Row="1"> <StackPanel Orientation="Horizontal"> <Button Margin="4,2" Command="{Binding CreateDocumentCommand}" CommandParameter="{Binding ElementName=grid, Path=CurrentItem}" Content="Create Document" /> </StackPanel> </GroupBox> </Grid> </UserControl>
DXDocumentUIServiceSample/ViewModel/MainViewModel.cs(vb)
C#
using DevExpress.Mvvm; using DevExpress.Mvvm.DataAnnotations; using DevExpress.Mvvm.Xpf; using DXDocumentUIServiceSample.Common; using System.Collections.ObjectModel; using System.Linq; namespace DXDocumentUIServiceSample.ViewModel { public class MainViewModel : ViewModelBase { IDocumentManagerService DocumentManagerService { get { return this.GetService<IDocumentManagerService>(); } } public ObservableCollection<UserViewModel> Users { get { return GetValue<ObservableCollection<UserViewModel>>(); } set { SetValue(value); } } public MainViewModel() { Users = DataHelper.GetUsers(); } [Command] public void DoubleClick(RowClickArgs args) { CreateDocument(args.Item); } [Command] public void CreateDocument(object viewModel) { var doc = DocumentManagerService.FindDocument(viewModel); if(doc == null) { doc = DocumentManagerService.CreateDocument("DetailedView", viewModel); doc.Id = DocumentManagerService.Documents.Count(); } doc.Show(); } } }
DXDocumentUIServiceSample/ViewModel/UserViewModel.cs(vb)
C#
using DevExpress.Mvvm; using DevExpress.Mvvm.DataAnnotations; using DXDocumentUIServiceSample.Common; using System; using System.Collections.ObjectModel; namespace DXDocumentUIServiceSample.ViewModel { public class UserViewModel : ViewModelBase, IDocumentContent { public int ID { get { return GetValue<int>(); } set { SetValue(value); } } public string NickName { get { return GetValue<string>(); } set { SetValue(value); } } public DateTime Registration { get { return GetValue<DateTime>(); } set { SetValue(value); } } public decimal Rating { get { return GetValue<decimal>(); } set { SetValue(value); } } public ObservableCollection<ActionsPerMonth> GlobalUserActivity { get { return GetValue<ObservableCollection<ActionsPerMonth>>(); } set { SetValue(value); } } public ObservableCollection<ActionsPerMonth> LocalUserActivity { get { return GetValue<ObservableCollection<ActionsPerMonth>>(); } set { SetValue(value); } } [Command] public void Close() { DocumentOwner.Close(this, false); } #region IDocumentContent public IDocumentOwner DocumentOwner { get; set; } public void OnClose(System.ComponentModel.CancelEventArgs e) { } public void OnDestroy() { } public object Title { get { return $"{NickName} ({Registration.ToShortDateString()})"; } } #endregion } }

Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.