<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: 2.1 LegendItems Always Null in ArcGIS API for Silverlight Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/2-1-legenditems-always-null/m-p/510182#M13048</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Bingo, that did it... Thanks a lot!!!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Legend.Refreshed is called a bunch of times, so I just check for when &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Legend.LayerItems&lt;I&gt;.LayerItems != null&lt;/I&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;and then set it at that point.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks a again!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 19 Nov 2010 13:59:58 GMT</pubDate>
    <dc:creator>RyanCoodey</dc:creator>
    <dc:date>2010-11-19T13:59:58Z</dc:date>
    <item>
      <title>2.1 LegendItems Always Null</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/2-1-legenditems-always-null/m-p/510178#M13044</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;- In the Legend.Loaded event, LayerItems is set but inside each of the items, it's LegendItems is always null.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;- In the LayerItem&lt;I&gt;.PropertyChanged event, e.PropertyName is never equal to "LegendItems"&lt;/I&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;- Even if I pause the application after I have viewed some legend items in tree view, the LegendItems are still null (for all LayerItems layers)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Since Raster Catalogs classified renderers do not come through the REST legend, I am trying to load custom images into LegendItems... but since they are always null, I'm not sure when I can do this.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks a lot for any help!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Nov 2010 19:45:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/2-1-legenditems-always-null/m-p/510178#M13044</guid>
      <dc:creator>RyanCoodey</dc:creator>
      <dc:date>2010-11-18T19:45:49Z</dc:date>
    </item>
    <item>
      <title>Re: 2.1 LegendItems Always Null</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/2-1-legenditems-always-null/m-p/510179#M13045</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I think the best event to subscribe to is Map.Layers.LayersInitialized but make sure that you only check this once because the LayerCollection change will trigger this event again.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;LegendItems will not be null for the case when the layer comes from a service created by ArcGIS Server 10 SP1 &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/arcgisserver/10.0/apis/rest/index.html" rel="nofollow noopener noreferrer" target="_blank"&gt;http://help.arcgis.com/en/arcgisserver/10.0/apis/rest/index.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;To load your custom image for a legend item, you can do the following:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
&amp;nbsp; public MainPage()
&amp;nbsp; {
&amp;nbsp;&amp;nbsp; InitializeComponent();
&amp;nbsp;&amp;nbsp; this.MyMap.Layers.LayersInitialized += Layers_LayersInitialized;
&amp;nbsp; }
&amp;nbsp; bool allLayersInitialized;
&amp;nbsp; void Layers_LayersInitialized(object sender, EventArgs args)
&amp;nbsp; {
&amp;nbsp;&amp;nbsp; if (!allLayersInitialized)
&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp; foreach (var l in this.MyLegend.LayerItems)
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (l.LegendItems == null)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; l.LegendItems = new ObservableCollection&amp;lt;LegendItemViewModel&amp;gt;();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; l.LegendItems.Add(new LegendItemViewModel() { ImageSource = new BitmapImage(new Uri("/image/car-blue-32x32.png", UriKind.Relative)), Description = "test" });
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }

&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; allLayersInitialized = true;
&amp;nbsp;&amp;nbsp; }&amp;nbsp;&amp;nbsp; 
&amp;nbsp; }
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 22:20:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/2-1-legenditems-always-null/m-p/510179#M13045</guid>
      <dc:creator>JenniferNery</dc:creator>
      <dc:date>2021-12-11T22:20:45Z</dc:date>
    </item>
    <item>
      <title>Re: 2.1 LegendItems Always Null</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/2-1-legenditems-always-null/m-p/510180#M13046</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks Jennifer, this gets me closer but still having some issues...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If I set:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Legend.LayerItems&lt;I&gt;.LegendItems = newLegendItems;&lt;/I&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;It works but the legend is created at the service level and is drawn there, it needs to be at a sub-layer... &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So I try to go one more level deeper at try:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Legend.LayerItems&lt;I&gt;.LayerItems&lt;J&gt;.LegendItems = newLegendItems;&lt;/J&gt;&lt;/I&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;but the second LayerItems collection is null... this should be the first row of actual layers in the service right?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Legend.LayerItems&lt;I&gt; is the Service (aka, MapLayer)&lt;/I&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Legend.LayerItems&lt;I&gt;.LayerItems&lt;J&gt; is the first set of Layers&lt;/J&gt;&lt;/I&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;right?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also, a bit of a side question, I am using ArcGIS Server 10 SP1, but all the Legend.LayerItems&lt;I&gt; are null... does this mean the legend is going out and using ESRI's legend REST service?&amp;nbsp; All my services were published in 10 before SP1, do I need to publish them again?&amp;nbsp; I tried publishing one from Desktop 10 SP1 and it still is null in the API...&lt;/I&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks again Jennifer!!!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Nov 2010 22:25:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/2-1-legenditems-always-null/m-p/510180#M13046</guid>
      <dc:creator>RyanCoodey</dc:creator>
      <dc:date>2010-11-18T22:25:16Z</dc:date>
    </item>
    <item>
      <title>Re: 2.1 LegendItems Always Null</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/2-1-legenditems-always-null/m-p/510181#M13047</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Legend.LayerItems&lt;I&gt;.LayerItems&lt;J&gt;.LegendItems = newLegendItems;&lt;BR /&gt;but the second LayerItems collection is null... this should be the first row of actual layers in the service right?&lt;BR /&gt;&lt;/J&gt;&lt;/I&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt;Right.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Perhaps the items are not yet initialized when you ran your code.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The best is to use the 'Legend.Refreshed' event for adding/removing/modifying any item you want.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt; &lt;BR /&gt;Legend.LayerItems&lt;I&gt; is the Service (aka, MapLayer)&lt;BR /&gt;Legend.LayerItems&lt;I&gt;.LayerItems&lt;J&gt; is the first set of Layers&lt;BR /&gt;right?&lt;BR /&gt;&lt;/J&gt;&lt;/I&gt;&lt;/I&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt;Right&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt; &lt;BR /&gt;Also, a bit of a side question, I am using ArcGIS Server 10 SP1, but all the Legend.LayerItems&lt;I&gt; are null... does this mean the legend is going out and using ESRI's legend REST service? All my services were published in 10 before SP1, do I need to publish them again? I tried publishing one from Desktop 10 SP1 and it still is null in the API...&lt;BR /&gt;&lt;/I&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt;No, the usage of 10SP1 or of the arcgis.com is transparent. The same legend item tree is created.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;More likely you tested before the legend tree was populated. Use the legend.refreshed event for that.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Nov 2010 11:52:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/2-1-legenditems-always-null/m-p/510181#M13047</guid>
      <dc:creator>DominiqueBroux</dc:creator>
      <dc:date>2010-11-19T11:52:15Z</dc:date>
    </item>
    <item>
      <title>Re: 2.1 LegendItems Always Null</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/2-1-legenditems-always-null/m-p/510182#M13048</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Bingo, that did it... Thanks a lot!!!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Legend.Refreshed is called a bunch of times, so I just check for when &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Legend.LayerItems&lt;I&gt;.LayerItems != null&lt;/I&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;and then set it at that point.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks a again!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Nov 2010 13:59:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/2-1-legenditems-always-null/m-p/510182#M13048</guid>
      <dc:creator>RyanCoodey</dc:creator>
      <dc:date>2010-11-19T13:59:58Z</dc:date>
    </item>
    <item>
      <title>Re: 2.1 LegendItems Always Null</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/2-1-legenditems-always-null/m-p/510183#M13049</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Great!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt; &lt;BR /&gt;Legend.Refreshed is called a bunch of times&lt;BR /&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;It's fired each time the legend tree associated to a maplayer changes.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;So at initialization, it is called once by map layer when the legend tree is ready to be rendered (and the eventargs e.LayerItem allows to retrieve which maplayer legend is just initialized).&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Then it is fired when the legend tree changes, i.e. when some legend items or legend layers are added/removed/changed.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;For example when a layer is added/removed , or when a renderer for a feature layer changes.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;So instead of testing 'Legend.LayerItems&lt;I&gt;.LayerItems != null', you could test 'if (e.LayerItem.Layer.ID == "MyRasterCatalogID") { ... }' and your code should be executed only once.&lt;/I&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;But it's OK as well as you did. It's only for info:)&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Nov 2010 14:35:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/2-1-legenditems-always-null/m-p/510183#M13049</guid>
      <dc:creator>DominiqueBroux</dc:creator>
      <dc:date>2010-11-19T14:35:14Z</dc:date>
    </item>
    <item>
      <title>Re: 2.1 LegendItems Always Null</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/2-1-legenditems-always-null/m-p/510184#M13050</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Ah, very cool, great tip... that should make my code a little more efficent.&amp;nbsp; Thanks Dom!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In the hopes to maybe help someone else out, here is what I did:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have a wrapped template control around the ESRI legend control and it has its own LegendRefreshed which can be used by its consuming application.&amp;nbsp; That consuming application can then subsicribe to this event and do as Dom said to get the Service layer and then call this method:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public void SetCustomLegend(LayerItemViewModel serviceLayerItemViewModel, String layerID, ObservableCollection&amp;lt;LegendItemViewModel&amp;gt; legendItems)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LayerItemViewModel layerItemViewModel = GetLegendLayer(serviceLayerItemViewModel, layerID);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (layerItemViewModel != null)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; layerItemViewModel.LegendItems = legendItems;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;GetLegendLayer() is a part recursive, part iterative method to then get a sub-layer of the Map Layer (Service), because "e.LayerItem.Layer.ID" seems to only trigger at the Map Layer level.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; protected LayerItemViewModel GetLegendLayer(LayerItemViewModel parentLayer, String layerID)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(parentLayer.LayerItems != null)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for (Int32 i = 0; i &amp;lt; parentLayer.LayerItems.Count; i++)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //If match, return it
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (parentLayer.LayerItems&lt;I&gt;.Label == layerID)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return parentLayer.LayerItems&lt;I&gt;;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Check sub layers
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LayerItemViewModel layerItemViewModel = GetLegendLayer(parentLayer.LayerItems&lt;I&gt;, layerID);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (layerItemViewModel != null)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return layerItemViewModel;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Continue checking other layers
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return null;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Maybe there is a better way to do this... but it is working for me currently.&amp;nbsp; Havn't tested it much yet though.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks again!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 22:20:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/2-1-legenditems-always-null/m-p/510184#M13050</guid>
      <dc:creator>RyanCoodey</dc:creator>
      <dc:date>2021-12-11T22:20:48Z</dc:date>
    </item>
    <item>
      <title>Re: 2.1 LegendItems Always Null</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/2-1-legenditems-always-null/m-p/510185#M13051</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;slight deviation,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I hope someone can shed some light on this for me.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have a couple of map services (created using 9.3.1) and I was trying to use the legend widget referencing the 2.1 JS API. This is however not working right. The container to hold the legend displays "Loading Legend..." then after a few seconds says "no legend to display". This might be a daft question but is the legend widget backward compatible? is anyone else experiencing this?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any help would be very much appreciated.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 21 Nov 2010 16:57:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/2-1-legenditems-always-null/m-p/510185#M13051</guid>
      <dc:creator>AlexanderAnkrah</dc:creator>
      <dc:date>2010-11-21T16:57:34Z</dc:date>
    </item>
    <item>
      <title>Re: 2.1 LegendItems Always Null</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/2-1-legenditems-always-null/m-p/510186#M13052</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Don,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Looks like you are working with JavaScript API, not with Silverlight.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;You might have more chance to get an answer by posting your question on this forum : &lt;/SPAN&gt;&lt;A href="http://forums.arcgis.com/forums/15-ArcGIS-API-for-JavaScript"&gt;http://forums.arcgis.com/forums/15-ArcGIS-API-for-JavaScript&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Nov 2010 08:41:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/2-1-legenditems-always-null/m-p/510186#M13052</guid>
      <dc:creator>DominiqueBroux</dc:creator>
      <dc:date>2010-11-22T08:41:13Z</dc:date>
    </item>
    <item>
      <title>Re: 2.1 LegendItems Always Null</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/2-1-legenditems-always-null/m-p/510187#M13053</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;OK. I have found the course of my woes. But that presents another major problem all together!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;just found out the Legend Widget does not support MapService URL with Tokens at the end for Secured Services...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Has anyone got a take on this please.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Nov 2010 09:25:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/2-1-legenditems-always-null/m-p/510187#M13053</guid>
      <dc:creator>AlexanderAnkrah</dc:creator>
      <dc:date>2010-11-22T09:25:15Z</dc:date>
    </item>
    <item>
      <title>Re: 2.1 LegendItems Always Null</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/2-1-legenditems-always-null/m-p/510188#M13054</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Bo! Sorry about that silverlight Folks...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Nov 2010 09:26:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/2-1-legenditems-always-null/m-p/510188#M13054</guid>
      <dc:creator>AlexanderAnkrah</dc:creator>
      <dc:date>2010-11-22T09:26:01Z</dc:date>
    </item>
  </channel>
</rss>

