I am working with ActiveMapViewChanged event as shown in the code snippet.
<SPAN class="keyword token">private</SPAN> <SPAN class="keyword token">void</SPAN> <SPAN class="token function">SubscribeMapEvents</SPAN><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="punctuation token">.</SPAN>
ActiveMapViewChangedEvent<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Subscribe</SPAN><SPAN class="punctuation token">(</SPAN>UpdateUIElements<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">UpdateUIElements</SPAN><SPAN class="punctuation token">(</SPAN>ActiveMapViewChangedEventArgs obj<SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">{</SPAN>
<SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN>obj<SPAN class="punctuation token">.</SPAN>IncomingView <SPAN class="operator token">!=</SPAN> <SPAN class="keyword token">null</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">{</SPAN>
<SPAN class="token function">ReInitializeUIElements</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">else</SPAN>
<SPAN class="punctuation token">{</SPAN>
<SPAN class="token function">ResetUIElements</SPAN><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="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>Idea is to
- update the UI elements with the information from MapView when it changes and
- reset to initial state when there is no map view.
The event triggers correctly when there is no map with IncomingView value as null, and when it updates the event is triggered with active map view's instance in the IncomingView parameter.
Whereas, when I open an attribute table from Table of contents with an active map, this event is triggered twice.
- First time with IncomingView as null and
- the second time with the active map view's instance.
This behavior is causing an unwanted reset of the controls even when there is an active map present.