ProSnippets CustomPaneWithContents - kataya/arcgis-pro-sdk GitHub Wiki

All ProSnippets listed here are also used by the following sample code: CustomPaneWithContents sample code

Language:              C#  
Subject:               Map-Exploration  
Contributor:           ArcGIS Pro SDK Team <[email protected]>  
Organization:          esri, http://www.esri.com  
Date:                  12/11/2020  
ArcGIS Pro:            2.7  
Visual Studio:         2017, 2019  
.NET Target Framework: 4.8  

CustomPaneViewModel

Create a Contents Control for a Custom View

Create a contents control to be shown as the TOC when the View is activated.

The contents will be shown in the Contents Dock Pane when the IContentsProvider (i.e. your Pane) is the active pane

private Contents _contents;

public Contents Contents
{
    get
    {
        if (_contents == null)
        {
            //This is your user control to be used as contents
            FrameworkElement contentsControl = new CustomPaneContentsControl()
            {
                //Vanilla MVVM here
                DataContext = this//This can be any custom view model
            };

            //This is the Pro Framework contents control wrapper
            _contents = new Contents()
            {
                //The view is your user control
                ContentsView = contentsControl,
                ContentsViewModel = this,//This is your pane view model
                OperationManager = this.OperationManager//optional
            };
        }
        return _contents;
    }
}
⚠️ **GitHub.com Fallback** ⚠️