TabbedWindowDocumentUIService

  • 4 minutes to read

The TabbedWindowDocumentUIService is an IDocumentManagerService implementation that allows you to show documents as DXTabControl's DXTabItems.

TabbedWindowDocumentUIService

Getting Started

Assume that you need to implement a tabbed document UI using the DXTabControl component. End-users can click a button (suppose it is a BarButtonItem object) to create a new document and show it as a full-fledged DXTabItem.

To accomplish this task, attach the TabbedWindowDocumentUIService service to MainView's DXTabControl.

<dx:DXTabControl>
    <dxmvvm:Interaction.Behaviors>
        <dx:TabbedWindowDocumentUIService  />
    </dxmvvm:Interaction.Behaviors>
    ...
</dx:DXTabControl>
NOTE

Since the TabbedWindowDocumentUIService is intended for tight integration with the DXTabbedWindow and its root DXTabControl, it cannot be used with nested (nonroot) DXTabControls.

Then, access the attached service from your ViewModel using one of ways described in the Services in ViewModelBase descendants and Services in POCO objects topics, and manage tabbed documents.

Below is a code snippet illustrating how to bind the BarButtonItem of a RibbonControl placed in the DXTabControl.ContentHeaderTemplate area to a command that uses one of the extension CreateDocument methods of the DocumentManagerServiceExtensions class; and show the newly created document using its IDocument.Show method.

<dx:DXTabControl.ContentHeaderTemplate>
    <DataTemplate>
        <dxr:RibbonControl  ... >
            <dxr:RibbonDefaultPageCategory Caption="Default Category">
                <dxr:RibbonPage Caption="Home">
                    <dxr:RibbonPageGroup Caption="Management">
                        <dxb:BarButtonItem 
                            Content="Add New Document" 
                            Command="{Binding CreateDocumentCommand}" 
                            LargeGlyph="{dx:DXImage Image=AddGroupFooter_32x32.png}" 
                            RibbonStyle="Large"/>
                        ...
                    </dxr:RibbonPageGroup>
                </dxr:RibbonPage>
            </dxr:RibbonDefaultPageCategory>
        </dxr:RibbonControl>
    </DataTemplate>
</dx:DXTabControl.ContentHeaderTemplate>
public class MainViewModel {
    protected IDocumentManagerService DocumentManagerService { get { return this.GetService<IDocumentManagerService>(); } }

    public void CreateDocument() {
        IDocument doc = DocumentManagerService.CreateDocument("TabView", ViewModelSource.Create(()=> new TabViewModel()));
        doc.Id = String.Format("DocId_{0}", DocumentManagerService.Documents.Count<IDocument>());
        doc.Title = String.Format("Item {0}", DocumentManagerService.Documents.Count<IDocument>());
        doc.Show();
    }

    public void CloseDocument() {
        DocumentManagerService.ActiveDocument.Close();
    }
}

To get the detailed information about the document processing mechanism, refer to the Document Management System topic.

Customization Options

TabbedWindowDocumentUIService provides a set of properties that allow you to customize the document's view.

These properties are used by the view creation mechanism. You can learn more about them in the following topic: View creation mechanisms

There are also properties that are used to customize the document's container.

  • NewItemTemplate gets or sets a DXTabItem object that will be used as a new item.
  • ItemTemplate gets or sets a DXTabItem object that will be used as a common item.

Example

Imports DevExpress.Mvvm
Imports DevExpress.Mvvm.POCO
Imports DevExpress.Mvvm.DataAnnotations
Imports System
Imports System.Linq

Namespace DXSample.ViewModel
    <POCOViewModel> _
    Public Class MainViewModel
        Protected ReadOnly Property DocumentManagerService() As IDocumentManagerService
            Get
                Return Me.GetService(Of IDocumentManagerService)()
            End Get
        End Property

        Public Sub CreateDocument()
            Dim doc As IDocument = DocumentManagerService.CreateDocument("TabView", ViewModelSource.Create(Function() New TabViewModel()))
            doc.Id = String.Format("DocId_{0}", DocumentManagerService.Documents.Count())
            doc.Title = String.Format("Item {0}", DocumentManagerService.Documents.Count())
            doc.Show()
        End Sub

        Public Sub CloseDocument()
            DocumentManagerService.ActiveDocument.Close()
        End Sub
    End Class
End Namespace