This method must be called on the UI thread (and not the MCT as is most commonly the case with most other synchronous API methods) or an System.InvalidOperationException will be thrown. The layout view you are deactivating the ActivatedMapFrame "on" must be the current active view or an System.InvalidOperationException will be thrown. The deactivated map frame will remain selected.
//The active view must be a layout view.
var lv = LayoutView.Active;
if (lv == null)
return;
var layout = lv.Layout;
if (layout == null)
return;
//Deactivate any activated map frame
//Note: we are on the UI thread!
lv.DeactivateMapFrame();//no-op if nothing activated
//or - check if a map frame is activated first...
if (lv.ActivatedMapFrame != null)
//Note: we are on the UI thread!
lv.DeactivateMapFrame();