Create custom Layout settings

1010
4
06-11-2021 07:20 AM
FlorianHoffmann2
New Contributor II

Hello, I found this nice article about adding a custom project/application settings page using the SDK:

https://community.esri.com/t5/arcgis-pro-sdk-blog/create-custom-project-and-application-settings-usi...

<!-- Project -->
</modules>
	<propertySheets>
		<updateSheet refID="esri_core_optionsPropertySheet">
			<insertPage id="esri_sdk_PropertyPageProjectSettings"
						caption="Sample Project Settings"
						className="ProjectSettingsViewModel"
						group="Project">
							<content className="ProjectSettingsView" />
			</insertPage>
		</updateSheet>
	</propertySheets>
</ArcGIS>

<!-- Application -->
</modules>
	<propertySheets>
		<updateSheet refID="esri_core_optionsPropertySheet">
			<insertPage id="esri_sdk_PropertyPageAppSettings"
						caption="Sample App Settings"
						className="ApplicationSettingsViewModel"
						group="Application">
							<content className="ApplicationSettingsView" />
			</insertPage>
		</updateSheet>
	</propertySheets>
</ArcGIS>‍‍‍‍‍‍‍‍‍‍‍‍

 

Theoretically, it should only be necessary to identify the group-id for the property window of layouts.

Practically, however, there is only one application and one project (at runtime) and several layouts. Which is probably a problem.

So, it is possible?

Thanks in advance!

0 Kudos
4 Replies
FlorianHoffmann2
New Contributor II

I made some progess:

    <propertySheets>
      <updateSheet refID="esri_layouts_propertySheet">
        <insertPage  id="esri_sdk_PropertyPageLayoutSettings"
						caption="Sample Layout Settings"
						className="LayoutSettingsViewModel">
							<content className="ProjectSettingsView" />
			</insertPage>
      </updateSheet>
    </propertySheets>

 

FlorianHoffmann2_0-1623424394255.png

 

I will keep this thread updated, perhaps someone else will find it useful.

0 Kudos
Wolf
by Esri Regular Contributor
Esri Regular Contributor

I attached my sample

Wolf_0-1623427208355.png

 

To implement the sample i added a property sheet (via New Project Item template) and then used you updateSheet daml above to show the property sheet (that i created) under the layout properties dialog .  I didn't delete the auto-inserted propertysheet daml yet (for illustration).

Note: 

in the config.daml of the sample please check the desktopVersion="2.9...." attribute for the AddInInfo tag.  Make sure to set it to the version of ArcGIS Pro that you are running: i.e. 2.7.0, 2.6.0 .... Otherwise the sample won't work for you.

FlorianHoffmann2
New Contributor II

Thanks for that, I was at a similarly state 😁!
So I wasn't wrong with my code.

My current problem is to identify the layout-instance inside the wpf-control.

But I think I got it (with your example):
The "PropertyPage1ViewModel" will be instantiated by Pro, Data[0] will be set to the layout-instance.
Then the custom-control "PropertyPage1View" (User-Control) ist created. After the constructor (not at it's end!) the DataContext-Property will be set to the the instance of the view-model.

The next step is to find out, how I should write and read the settings with the module "OnReadSettingsAsync/OnWriteSettingsAsync" (best practice).

0 Kudos
CharlesMacleod
Esri Regular Contributor

contextually, assuming it is the active layout u are after, you can retrieve that from LayoutView.Active. The active layout view provides access to the layout it is rendering via layoutView.Layout.

 

Note also, in MVVM, your code should really be in the view model (not the view). Thus, u typically dont need access to the view model in the view (via its data context). In your case, the view model is identified by the className attribute on the "insertPage" tag.

 

Some (hopefully) useful references:

https://github.com/esri/arcgis-pro-sdk/wiki/ProGuide-Custom-settings

ArcGIS Pro SDK for .NET: Advanced Pro Customization with Focus on Categories and Custom Settings 

0 Kudos