I noticed some quirky behavior with getting the MapURI out of certain panes. I'm using ArcGIS Pro 2.2.4.
Based on https://community.esri.com/message/911800-activemapviewchanged-event-fires-twice#comment-914434, I was getting the related Map's URI from an attribute table pane.
<SPAN class="punctuation token">.</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="punctuation token">.</SPAN>
ActivePaneChangedEvent<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Subscribe</SPAN><SPAN class="punctuation token">(</SPAN>OnActivePaneChanged<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">.</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="punctuation token">.</SPAN>
<SPAN class="keyword token">private</SPAN> <SPAN class="keyword token">void</SPAN> <SPAN class="token function">OnActivePaneChanged</SPAN><SPAN class="punctuation token">(</SPAN>PaneEventArgs args<SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">{</SPAN>
<SPAN class="keyword token">var</SPAN> inPane <SPAN class="operator token">=</SPAN> args<SPAN class="punctuation token">.</SPAN>IncomingPane <SPAN class="keyword token">as</SPAN> TOCActiveMapViewProviderPane<SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">var</SPAN> inURI <SPAN class="operator token">=</SPAN> inPane<SPAN class="operator token">?</SPAN><SPAN class="punctuation token">.</SPAN>MapURI<SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>When initially loaded, sometimes inPane?.MapURI is empty ("") even when inPane is not null. Later in the same program, it may return the correct value. The little experimentation I've done so far, shows having a "(" in the FeatureLayer's alias seemed to lead to the empty initial MapURI value.
1) Has anyone else seen this?
2) Are there any more details on when this should and shouldn't work? or how to work around it?
Thanks much!
possibly related to this note from:
https://community.esri.com/message/875696-re-drag-drop-into-a-dockpane?commentID=875696#comment-875696
<SPAN class="" style="color: slategray; border: 0px; font-weight: inherit;">//last, get the source map to which the map members belong</SPAN>
<SPAN class="" style="color: #0077aa; border: 0px; font-weight: inherit;">var</SPAN> mapuri <SPAN class="" style="color: #a67f59; background: rgba(255, 255, 255, 0.5); border: 0px; font-weight: inherit;">=</SPAN> dropInfo<SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;">.</SPAN><SPAN class="" style="color: #d74444; border: 0px; font-weight: inherit;">GetMapUri</SPAN><SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;">(</SPAN><SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;">)</SPAN><SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;">;</SPAN>
<SPAN class="" style="color: slategray; border: 0px; font-weight: inherit;">//99 times out of a 100 this will be the active view map....</SPAN>
<SPAN class="" style="color: slategray; border: 0px; font-weight: inherit;">//but, if not, get the actual map (or scene) this way</SPAN>
<SPAN class="" style="color: #0077aa; border: 0px; font-weight: inherit;">var</SPAN> map <SPAN class="" style="color: #a67f59; background: rgba(255, 255, 255, 0.5); border: 0px; font-weight: inherit;">=</SPAN> FrameworkApplication<SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;">.</SPAN>Panes<SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;">.</SPAN>OfType<SPAN class="" style="color: #a67f59; background: rgba(255, 255, 255, 0.5); border: 0px; font-weight: inherit;"><</SPAN>IMapPane<SPAN class="" style="color: #a67f59; background: rgba(255, 255, 255, 0.5); border: 0px; font-weight: inherit;">></SPAN><SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;">(</SPAN><SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;">)</SPAN><SPAN class="" style="color: #a67f59; background: rgba(255, 255, 255, 0.5); border: 0px; font-weight: inherit;">?</SPAN><SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;">.</SPAN><SPAN class="" style="color: #d74444; border: 0px; font-weight: inherit;">Select</SPAN><SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;">(</SPAN>mp <SPAN class="" style="color: #a67f59; background: rgba(255, 255, 255, 0.5); border: 0px; font-weight: inherit;">=</SPAN><SPAN class="" style="color: #a67f59; background: rgba(255, 255, 255, 0.5); border: 0px; font-weight: inherit;">></SPAN> mp<SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;">.</SPAN>MapView<SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;">.</SPAN>Map<SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;">)</SPAN>
<SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;">.</SPAN><SPAN class="" style="color: #d74444; border: 0px; font-weight: inherit;">Where</SPAN><SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;">(</SPAN>m <SPAN class="" style="color: #a67f59; background: rgba(255, 255, 255, 0.5); border: 0px; font-weight: inherit;">=</SPAN><SPAN class="" style="color: #a67f59; background: rgba(255, 255, 255, 0.5); border: 0px; font-weight: inherit;">></SPAN> m<SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;">.</SPAN>URI <SPAN class="" style="color: #a67f59; background: rgba(255, 255, 255, 0.5); border: 0px; font-weight: inherit;">==</SPAN> mapuri<SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;">)</SPAN><SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;">.</SPAN><SPAN class="" style="color: #d74444; border: 0px; font-weight: inherit;">First</SPAN><SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;">(</SPAN><SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;">)</SPAN><SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;">;</SPAN>