I can not seem to figure out how to add a background color to an ArcGIS Pro map frame using C# in ArcGIS Pro SDK. For example, I can programmatically add a new map frame to a layout, but I would then like to set a blue background color for the map frame. I cannot seem to find any documentation on this. Any help would be much appreciated.
If the API doesn't expose a method or property for your needs you can usually try the underlying 'Cartographic Information Model' (CIM) for that class. So specifically for the Map class you can find a BackgroundColor property in the corresponding CIMMap class. This code snippet will work for you:
if (MapView.Active?.Map == null) return;
var cimMap = MapView.Active.Map.GetDefinition();
cimMap.BackgroundColor = CIMColor.CreateRGBColor(0, 0, 255, 138);
Hope this helps.
Thank you. The solution above, added a blue background to the active map within my map frame, but did not add a blue background to the map frame (within the layout view) itself. I am trying to change the background symbol (located in the format map frame pane) to blue (see image).
I'm wondering if anyone has any knowledge on using ArcGIS Pro SDK to add a background color to the map frame itself. Here is a graphic that displays the background feature that I am trying to change to blue.
Here is a code snippet that can change the map frame's background.
protected override void OnClick()
//Get the layout
var layout = Project.Current.GetItems<LayoutProjectItem>()?.First().GetLayout();
if (layout == null) return;
//Get the map frame in the layout
MapFrame mapFrame = layout.FindElement("New Map Frame") as MapFrame;
if (mapFrame == null)
ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("Map frame not found", "WARNING");
//Get the map frame's definition in order to modify the background.
var mapFrameDefn = mapFrame.GetDefinition() as CIMMapFrame;
//Construct the polygon symbol to use to create a background
var polySymbol = SymbolFactory.Instance.ConstructPolygonSymbol(ColorFactory.Instance.BlueRGB, SimpleFillStyle.Solid);
//Set the background
mapFrameDefn.GraphicFrame.BackgroundSymbol = polySymbol.MakeSymbolReference();
//Set the map frame defintion