<?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: Unable to get GetLegendInfosAsync() to work against my maps layers in .NET Maps SDK Questions</title>
    <link>https://community.esri.com/t5/net-maps-sdk-questions/unable-to-get-getlegendinfosasync-to-work-against/m-p/1372369#M12461</link>
    <description>&lt;P&gt;This is fixed.&amp;nbsp; I changed my methodology to handle the Task functionality using Task.WhenAll(legendTasks) instead, in order to wait for all the LegendInfos to get loaded prior to adding it to my observable collection.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 19 Jan 2024 17:23:43 GMT</pubDate>
    <dc:creator>KarenRobine1</dc:creator>
    <dc:date>2024-01-19T17:23:43Z</dc:date>
    <item>
      <title>Unable to get GetLegendInfosAsync() to work against my maps layers</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/unable-to-get-getlegendinfosasync-to-work-against/m-p/1372015#M12460</link>
      <description>&lt;P&gt;I'm trying to obtain LegendInfo's from all of my Feature Layers in my map (after they're loaded and shown on the map).&amp;nbsp; I've attempted to await on the Layer.GetLegendInfosAsync() using a couple of different methods, and the task status is&amp;nbsp; always set to WaitingForActivation.&amp;nbsp; I'm trying to place my Legends into a MAUI CollectionView.&amp;nbsp; If I show the layer again in my ContentView, it works the next time I open that ContentView, but not the first time.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;I've tried using the code in the LayerListDataSource (from the Legend Toolkit) as well as TocItem.cs (from the Table of Contents).&amp;nbsp;&lt;/P&gt;&lt;P&gt;I might be missing some of the code located in LayerContentDataSource.cs (from Legend Toolkit) but not sure..&lt;/P&gt;&lt;P&gt;Methods follow:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;//This is the version in LayerListDataSource.cs (tried with and without ConfigureAwait(false)&lt;BR /&gt;private async Task&amp;lt;IReadOnlyList&amp;lt;LegendInfo&amp;gt;&amp;gt; LoadLegendOrig(ILayerContent layer)&lt;BR /&gt;{&lt;BR /&gt;var result = await layer.GetLegendInfosAsync().ConfigureAwait(false);&lt;BR /&gt;if (result.Count &amp;gt; 0)&lt;BR /&gt;{&lt;BR /&gt;Debug.WriteLine($"TocViewModel.cs: LoadLegendOrig() result.Count &amp;gt; 0 = {result.Count}");&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;return result;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;//This is the version in TocItem.cs&lt;BR /&gt;private async Task&amp;lt;IReadOnlyList&amp;lt;LegendInfo&amp;gt;&amp;gt; LoadLegend(ILayerContent lc)&lt;BR /&gt;{&lt;BR /&gt;var task = lc.GetLegendInfosAsync();&lt;BR /&gt;if (task.IsCompleted)&lt;BR /&gt;{&lt;BR /&gt;await System.Threading.Tasks.Task.Yield();&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;var infos = await task;&lt;BR /&gt;return infos;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jan 2024 00:08:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/unable-to-get-getlegendinfosasync-to-work-against/m-p/1372015#M12460</guid>
      <dc:creator>KarenRobine1</dc:creator>
      <dc:date>2024-01-19T00:08:53Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to get GetLegendInfosAsync() to work against my maps layers</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/unable-to-get-getlegendinfosasync-to-work-against/m-p/1372369#M12461</link>
      <description>&lt;P&gt;This is fixed.&amp;nbsp; I changed my methodology to handle the Task functionality using Task.WhenAll(legendTasks) instead, in order to wait for all the LegendInfos to get loaded prior to adding it to my observable collection.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jan 2024 17:23:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/unable-to-get-getlegendinfosasync-to-work-against/m-p/1372369#M12461</guid>
      <dc:creator>KarenRobine1</dc:creator>
      <dc:date>2024-01-19T17:23:43Z</dc:date>
    </item>
  </channel>
</rss>

