Hi,
I need to add functionality in the layout to allow the user to add multiple Map Frames as needed. I'm using the ArcGIS Pro tool functionality (Tool ID: esri_layouts_reshapeMapFrameRectangleTool) for this.
Below is the code snippet I have used:

-----------------------------------------------------------------------------------------------
//reusing the pro tool
public ICommand SelectLinearBandCommand =>
new ArcGIS.Desktop.Framework.RelayCommand(() =>
{
var SelectLinearBandcmd = FrameworkApplication.GetPlugInWrapper("esri_layouts_newMapFrameRectangleTool") as ICommand;
SelectLinearBandcmd.Execute(null);
LinearBandButton(layout, map, mfElm);
},
() => (FrameworkApplication.GetPlugInWrapper("esri_layouts_newMapFrameRectangleTool") as ICommand).CanExecute(null)
);
//made function "LinearBandButton" and called that into above command
private async void LinearBandButton(Layout layout, Map map, MapFrame mfElm)
{
await QueuedTask.Run(() =>
{
layout = LayoutFactory.Instance.CreateLayout(LayoutConstants.Width, LayoutConstants.Height, LayoutConstants.Units);
layout.SetName(LayoutName);
ArcGIS.Core.Geometry.Envelope env = EnvelopeBuilder.CreateEnvelope(LayoutConstants.xMin, LayoutConstants.yMin, LayoutConstants.xMax, LayoutConstants.yMax);
MapGlobal.Instance.envelope = env;
MapProjectItem mapPrjItem = Project.Current.GetItems<MapProjectItem>().FirstOrDefault(item => item.Name.Equals(LayoutConstants.MapName));
map = mapPrjItem.GetMap();
map.SetSpatialReference(sptlRef);
mfElm = LayoutElementFactory.Instance.CreateMapFrame(layout, env, map);
//When I add the Map Frame to the Layout, I want it to be called "Linear Band."
mfElm.SetName("Linear Band");
});
}
-------------------------------------------------------------------------
Issue: The issue is that I need to set name('Linear Band') after the Map Frame is added to the layout, but the setName functionality is currently running before that, so the name does not change from "Map Frame" to "Linear Band." When we add the Map Frame to the layout, the default name is "Map Frame," which I want to change to "Linear Band."
Could anyone please assist me in resolving this issue? It would be great if you could provide a code snippet on how to do so.
Thanks in advance.