<?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: Execute a Query of a Feature Layer from within a ProWindow in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/execute-a-query-of-a-feature-layer-from-within-a/m-p/1190385#M8354</link>
    <description>&lt;P&gt;I used your sample code (with a different dataset) and it worked fine.&amp;nbsp; &amp;nbsp;Here's my code:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;    private async void Test_Click(object sender, RoutedEventArgs e)
    {

      String layerName = "TestPoints";
      var fLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType&amp;lt;FeatureLayer&amp;gt;().FirstOrDefault(l =&amp;gt; l.Name.Equals(layerName));
      if (fLayer != null)
      {
        if (this.TbxPLUSCase.Text != null &amp;amp;&amp;amp; this.TbxPLUSCase.Text != "")
        {
          Dictionary&amp;lt;long, string&amp;gt; RoadDict = new Dictionary&amp;lt;long, string&amp;gt;();
          string whereClause = "TheString = '" + this.TbxPLUSCase.Text.ToUpper() + "'";
          QueryFilter qf = new QueryFilter();
          qf.WhereClause = whereClause;
          var iCount = await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =&amp;gt;
          {
            var cnt = 0;
            using (ArcGIS.Core.Data.Table PLUSTable = fLayer.GetTable())
            {
              using (RowCursor rowCursor = PLUSTable.Search(qf))
              {
                while (rowCursor.MoveNext())
                {
                  using (ArcGIS.Core.Data.Row row = rowCursor.Current)
                  {
                    string dictvalue = row["TheString"].ToString();
                    long v = Convert.ToInt64(row.GetObjectID().ToString());
                    RoadDict[v] = dictvalue;
                    cnt++;
                  };
                }
              }
            }
            return cnt;
          });
          MessageBox.Show($@"Records found: {iCount}");
        }

      }
      this.Close();
    }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You should be able to set a breakpoint inside the action for the QueuedTask.Run and step through the code.&amp;nbsp; I suggest that you also add a try {} catch {} to get any exceptions that are thrown by your code (i.e. misspelled field names).&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what I saw with my sample code running:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Wolf_0-1657205333847.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/45439i1D5B5541CA59CD30/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Wolf_0-1657205333847.png" alt="Wolf_0-1657205333847.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 07 Jul 2022 14:49:27 GMT</pubDate>
    <dc:creator>Wolf</dc:creator>
    <dc:date>2022-07-07T14:49:27Z</dc:date>
    <item>
      <title>Execute a Query of a Feature Layer from within a ProWindow</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/execute-a-query-of-a-feature-layer-from-within-a/m-p/1190204#M8347</link>
      <description>&lt;P&gt;I am trying to run a query on a FeatureLayer in the Active Map through a button in a ProWindow, but either the code throws a Thread Exception if I try to perform a Search on the Layer outside of an async/await block or it skips over the code inside the await portion.&lt;/P&gt;&lt;P&gt;Here is the code I have and I have tried it with and without the async/await code:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;        private async void Locate_Click(object sender, RoutedEventArgs e)
        {
            String layerName = "Search PLUS Cases";
            var fLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType&amp;lt;FeatureLayer&amp;gt;().FirstOrDefault(l =&amp;gt; l.Name.Equals(layerName));
            if (fLayer != null)
            {
                if (this.TbxPLUSCase.Text != null &amp;amp;&amp;amp; this.TbxPLUSCase.Text != "")
                {
                    Dictionary&amp;lt;long, string&amp;gt; RoadDict = new Dictionary&amp;lt;long, string&amp;gt;();
                    string whereClause = "CASE_ID = '" + this.TbxPLUSCase.Text.ToUpper() + "'";
                    QueryFilter qf = new QueryFilter();
                    qf.WhereClause = whereClause;
                    await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =&amp;gt;
                    {
                        using (ArcGIS.Core.Data.Table PLUSTable = fLayer.GetTable())
                        {
                            using (RowCursor rowCursor = PLUSTable.Search(qf))
                            {
                                while (rowCursor.MoveNext())
                                {
                                    using (ArcGIS.Core.Data.Row row = rowCursor.Current)
                                    {
                                        string dictvalue = row["CASE_ID"].ToString();
                                        long v = Convert.ToInt64(row["objectid"].ToString());
                                        RoadDict[v] = dictvalue;
                                    };
                                }
                            }
                        }
                    });
                }

            }
            this.Close();
        }&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 07 Jul 2022 00:38:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/execute-a-query-of-a-feature-layer-from-within-a/m-p/1190204#M8347</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2022-07-07T00:38:43Z</dc:date>
    </item>
    <item>
      <title>Re: Execute a Query of a Feature Layer from within a ProWindow</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/execute-a-query-of-a-feature-layer-from-within-a/m-p/1190385#M8354</link>
      <description>&lt;P&gt;I used your sample code (with a different dataset) and it worked fine.&amp;nbsp; &amp;nbsp;Here's my code:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;    private async void Test_Click(object sender, RoutedEventArgs e)
    {

      String layerName = "TestPoints";
      var fLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType&amp;lt;FeatureLayer&amp;gt;().FirstOrDefault(l =&amp;gt; l.Name.Equals(layerName));
      if (fLayer != null)
      {
        if (this.TbxPLUSCase.Text != null &amp;amp;&amp;amp; this.TbxPLUSCase.Text != "")
        {
          Dictionary&amp;lt;long, string&amp;gt; RoadDict = new Dictionary&amp;lt;long, string&amp;gt;();
          string whereClause = "TheString = '" + this.TbxPLUSCase.Text.ToUpper() + "'";
          QueryFilter qf = new QueryFilter();
          qf.WhereClause = whereClause;
          var iCount = await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =&amp;gt;
          {
            var cnt = 0;
            using (ArcGIS.Core.Data.Table PLUSTable = fLayer.GetTable())
            {
              using (RowCursor rowCursor = PLUSTable.Search(qf))
              {
                while (rowCursor.MoveNext())
                {
                  using (ArcGIS.Core.Data.Row row = rowCursor.Current)
                  {
                    string dictvalue = row["TheString"].ToString();
                    long v = Convert.ToInt64(row.GetObjectID().ToString());
                    RoadDict[v] = dictvalue;
                    cnt++;
                  };
                }
              }
            }
            return cnt;
          });
          MessageBox.Show($@"Records found: {iCount}");
        }

      }
      this.Close();
    }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You should be able to set a breakpoint inside the action for the QueuedTask.Run and step through the code.&amp;nbsp; I suggest that you also add a try {} catch {} to get any exceptions that are thrown by your code (i.e. misspelled field names).&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what I saw with my sample code running:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Wolf_0-1657205333847.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/45439i1D5B5541CA59CD30/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Wolf_0-1657205333847.png" alt="Wolf_0-1657205333847.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jul 2022 14:49:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/execute-a-query-of-a-feature-layer-from-within-a/m-p/1190385#M8354</guid>
      <dc:creator>Wolf</dc:creator>
      <dc:date>2022-07-07T14:49:27Z</dc:date>
    </item>
    <item>
      <title>Re: Execute a Query of a Feature Layer from within a ProWindow</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/execute-a-query-of-a-feature-layer-from-within-a/m-p/1190492#M8356</link>
      <description>&lt;P&gt;I made sure my code was fully consistent with the code you used and it worked when I launched the form directly.&lt;/P&gt;&lt;P&gt;However, I think the issue arose due to the fact that I originally was launching the search case ProWindow from another ProWindow where the user chooses a search to launch from several search options using radio buttons.&amp;nbsp; That was my original design for my ArcObjects Add-In using Windows Forms.&amp;nbsp; The initial Form also did some map set up validation steps through the Search button prior to launching a given search form.&amp;nbsp; However, I suspect that approach is creating too many complications in ArcGIS Pro, so I probably need to rethink the search selection part of the add-in.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ProWindowChoices.PNG" style="width: 346px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/45456i9AAB69009531EF18/image-size/large?v=v2&amp;amp;px=999" role="button" title="ProWindowChoices.PNG" alt="ProWindowChoices.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Would you recommend that I replace the initial ProWindow shown above with a toolbar that contains a dropdown menu of the search choices and a button that launches the appropriate ProWindow based on the kind of search chosen through the dropdown?&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jul 2022 18:10:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/execute-a-query-of-a-feature-layer-from-within-a/m-p/1190492#M8356</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2022-07-07T18:10:32Z</dc:date>
    </item>
    <item>
      <title>Re: Execute a Query of a Feature Layer from within a ProWindow</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/execute-a-query-of-a-feature-layer-from-within-a/m-p/1190757#M8362</link>
      <description>&lt;P&gt;I would recommend using a Dockpane instead of a ProWindow that works similar to the 'Locate' Dockpane in ArcGIS Pro:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Wolf_0-1657266749982.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/45528iD431BD5DBCC572F8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Wolf_0-1657266749982.png" alt="Wolf_0-1657266749982.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;On the top of your search Dockpane i would show a drop down that allows the user to select the type of search they want to perform.&amp;nbsp; Once the user selects the search method the fields specific to the search are displayed.&amp;nbsp; After the search completes the found records are displayed in a list below the search query info just like on the ArcGIS Pro locate dockpane.&amp;nbsp; &amp;nbsp;There are plenty of community samples that do something similar.&lt;/P&gt;&lt;P&gt;I attached a search sample dockpane that looks like this:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Wolf_0-1657273051816.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/45530iD9B98B983FC3F4C4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Wolf_0-1657273051816.png" alt="Wolf_0-1657273051816.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;However you implement this, i would avoid handing off the UI between different windows or dockpanes.&amp;nbsp; If you have to implement any type of map manipulation (depending on the user's search option selection) do it within a QueuedTask.Run and await the action.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jul 2022 13:43:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/execute-a-query-of-a-feature-layer-from-within-a/m-p/1190757#M8362</guid>
      <dc:creator>Wolf</dc:creator>
      <dc:date>2022-07-08T13:43:39Z</dc:date>
    </item>
    <item>
      <title>Re: Execute a Query of a Feature Layer from within a ProWindow</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/execute-a-query-of-a-feature-layer-from-within-a/m-p/1191082#M8370</link>
      <description>&lt;P&gt;The Search Forms layouts would have to undergo a huge redesign to fit in a single dockpane.&amp;nbsp; A Button and combobox in the Quick Access Toolbar is working out great.&amp;nbsp; The button launches the chosen search option as a modal ProWindow which has control over the application until the user either cancels the search dialog to close it or choses a valid feature or list of features and presses the Locate button, which closes the dialog and displays the features on the map.&amp;nbsp; The forms do not cover valuable screen area when they are not explicitly requested by the user.&amp;nbsp; My users are very familiar with how my forms behave in ArcMap and want the same experience in ArcGIS Pro.&lt;/P&gt;&lt;P&gt;I also do not see a benefit of keeping the form available in a dockpane and having to monitor everything the user might do in the project that would force the search in progress to reset itself.&amp;nbsp; The user is unlikely to know what would trigger a reset and do it without realizing why the search interface reset itself. In fact I don't know all of the possible things a user could do that should trigger a reset and don't want to try to imagine what they are or have to debug them all.&lt;/P&gt;&lt;P&gt;While some of the forms are tall and narrow and would easily work in a dockable window, other forms have to be quite wide to be useful.&amp;nbsp; I do not think redesigning those dialogs to fit in a single dockable window is really an option.&amp;nbsp; I also don't want to have to control the width of the dockable window or worry that the user might resize it in a way that would make the form unusable.&lt;/P&gt;&lt;P&gt;Anyway, here are the form designs I am trying to port which may give you a better idea of why I think using separate ProWindows is the best design.&amp;nbsp; So far, all indications are that I can make that design work now that only one ProWindow is open at a time and I am no longer calling a ProWindow from within another ProWindow.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Search Intersections.PNG" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/45623iDA2616FDA70F0393/image-size/large?v=v2&amp;amp;px=999" role="button" title="Search Intersections.PNG" alt="Search Intersections.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt; &lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Search APN.PNG" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/45613iDC5F0384110BC925/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Search APN.PNG" alt="Search APN.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Search APN Address.PNG" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/45621i488DEE9CF8998F05/image-size/large?v=v2&amp;amp;px=999" role="button" title="Search APN Address.PNG" alt="Search APN Address.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Search APN Owner.PNG" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/45622iB5108AD823EB7DEC/image-size/large?v=v2&amp;amp;px=999" role="button" title="Search APN Owner.PNG" alt="Search APN Owner.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt; &lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Search APN Subdivision.PNG" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/45616i63E4A8FFB2A57B4D/image-size/large?v=v2&amp;amp;px=999" role="button" title="Search APN Subdivision.PNG" alt="Search APN Subdivision.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt; &lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Search Point Address.PNG" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/45617iD310DE3D06976DA3/image-size/large?v=v2&amp;amp;px=999" role="button" title="Search Point Address.PNG" alt="Search Point Address.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Search Survey Legal.PNG" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/45625i82767B41F8001170/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Search Survey Legal.PNG" alt="Search Survey Legal.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Search Survey Subdivision.PNG" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/45626i33C774889B52F1CE/image-size/large?v=v2&amp;amp;px=999" role="button" title="Search Survey Subdivision.PNG" alt="Search Survey Subdivision.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt; &lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Search PLUS Cases.PNG" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/45618i8BB1D333DD52C052/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Search PLUS Cases.PNG" alt="Search PLUS Cases.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt; &lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Search Road Book Page.PNG" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/45619iABA1085742C5A641/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Search Road Book Page.PNG" alt="Search Road Book Page.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt; &lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Search Section Township Range.PNG" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/45620i7061B80AB5DB9047/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Search Section Township Range.PNG" alt="Search Section Township Range.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;</description>
      <pubDate>Sat, 09 Jul 2022 05:42:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/execute-a-query-of-a-feature-layer-from-within-a/m-p/1191082#M8370</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2022-07-09T05:42:29Z</dc:date>
    </item>
    <item>
      <title>Re: Execute a Query of a Feature Layer from within a ProWindow</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/execute-a-query-of-a-feature-layer-from-within-a/m-p/1191248#M8373</link>
      <description>&lt;P&gt;Looking at the complexity of your query forms it looks like the best way would be to use a ProWindow.&amp;nbsp; &amp;nbsp;You could use the tabcontrol that i showed in my Dockpane sample to put all your search forms into the same ProWindow, but i would definitely recommend switching to an MVVM based ProWindow.&amp;nbsp; There was a tech session at the 2022 Dev Summit that discussed ProWindow vs. Dockpane and assync processing and that might be helpful to you:&amp;nbsp;&amp;nbsp;&lt;A href="https://github.com/Esri/arcgis-pro-sdk/wiki/Tech-Sessions" target="_blank" rel="noopener"&gt;Tech Sessions · Esri/arcgis-pro-sdk Wiki (github.com)&lt;/A&gt;&amp;nbsp; click on "Improving Your Dockpane and ProWindow Design Patterns" in order to get the slides and code samples (in 2.x).&amp;nbsp; There might even be a video of this session available on YouTube or on&amp;nbsp;&lt;A href="https://mediaspace.esri.com/home" target="_blank"&gt;Esri Videos: GIS, Events, ArcGIS Products &amp;amp; Industries&lt;/A&gt;&amp;nbsp;(search for "Improving Your Dockpane and ProWindow Design Patterns").&amp;nbsp; As forms get more complex (and your forms definitely fall into that category) MVVM based forms are much easier to maintain.&amp;nbsp; It's a bit of a leap at first (coming from ArcMap winforms) but it will pay off in the long run.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jul 2022 14:50:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/execute-a-query-of-a-feature-layer-from-within-a/m-p/1191248#M8373</guid>
      <dc:creator>Wolf</dc:creator>
      <dc:date>2022-07-11T14:50:17Z</dc:date>
    </item>
  </channel>
</rss>

