<?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: AddIn Button won't populate Windows Form Listbox with returned string from web request in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/addin-button-won-t-populate-windows-form-listbox/m-p/1141402#M7746</link>
    <description>&lt;P&gt;Whole new world - maybe. More like a different planet. The "help" is unfortunately rather fragmented:&lt;/P&gt;&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/2.8/sdk/api-reference/index.html#topic1.html" target="_self"&gt;Reference&lt;/A&gt;&amp;nbsp; The reference for all the Pro objects. For the most part auto-generated and doesn't give you much more than what intellisense does.&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/Esri/arcgis-pro-sdk/wiki/ProSnippets" target="_self"&gt;Snippets&lt;/A&gt;&amp;nbsp; Bits of code to do various things. Very good, but requires a lot of searching through the various categories if you didn't create the SDK and thus don't know what's in all the various SDK assemblies.&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/Esri/arcgis-pro-sdk-community-samples" target="_self"&gt;Samples&lt;/A&gt;&amp;nbsp; Lots of very good samples. Requires some editing in wordpad of the .csproj files if you did not install ArcGIS in the default location.&lt;/P&gt;&lt;P&gt;The one you want to look at is under "Framework" called DockpaneSimple. It has a couple of listboxes. Pay attention to the Bindings in BookmarkDockpane.XAML for the listboxes, and the corresponding properties in BookmarkDockpaneViewModel.cs&amp;nbsp; That app makes a list of Bookmark names, but can just as easily be some text items you get from your WebResponse.&lt;/P&gt;&lt;P&gt;DockPanels don't go away once they are created, so if you want your app to work like a geoprocessing tool and go away once it's done doing it's work, you'll need to add this at the end:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;        DockPane dockPane = FrameworkApplication.DockPaneManager.Find(_dockPaneID);
        if (dockPane != null) { dockPane.IsVisible = false; }&lt;/LI-CODE&gt;&lt;P&gt;You can find what _docPaneID for your app is supposed to be in the Config.DAML for your addin.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 07 Feb 2022 22:07:19 GMT</pubDate>
    <dc:creator>BerndtNording</dc:creator>
    <dc:date>2022-02-07T22:07:19Z</dc:date>
    <item>
      <title>AddIn Button won't populate Windows Form Listbox with returned string from web request</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/addin-button-won-t-populate-windows-form-listbox/m-p/1140868#M7729</link>
      <description>&lt;P&gt;I'm a newbie at building AddIns with the Pro SDK.&lt;/P&gt;&lt;P&gt;I have created an ArcGIS Pro AddIn button using VS2017 C#. I am trying to get a Windows Form (frmSAPAttributes) Listbox (lstAttributes) to populate with a parsed JSON string. The parsing works, and I can display each string individually in a messagebox.show(), but when I try to add the items to my Windows Form Listbox during runtime, and show the form, the form is empty and it just hangs in Pro. The following is the section of code:&lt;/P&gt;&lt;P&gt;protected async override void OnClick()&lt;BR /&gt;{&lt;BR /&gt;await QueuedTask.Run(() =&amp;gt;&lt;BR /&gt;{&lt;BR /&gt;// get the currently selected features in the map&lt;BR /&gt;var selectedFeatures = ArcGIS.Desktop.Mapping.MapView.Active.Map.GetSelection();&lt;/P&gt;&lt;P&gt;// get the first layer and its corresponding selected feature OIDs&lt;BR /&gt;var firstSelectionSet = selectedFeatures.First();&lt;/P&gt;&lt;P&gt;// create an instance of the inspector class&lt;BR /&gt;var inspector = new ArcGIS.Desktop.Editing.Attributes.Inspector();&lt;/P&gt;&lt;P&gt;// load the selected features into the inspector using a list of object IDs&lt;BR /&gt;inspector.Load(firstSelectionSet.Key, firstSelectionSet.Value);&lt;/P&gt;&lt;P&gt;//get the value of&lt;BR /&gt;var pscode = inspector["SAP_ID"];&lt;BR /&gt;var SAPID = pscode.ToString();&lt;BR /&gt;var urlLink = "&lt;A href="http://sappsprod.marinwater.local:8000/equi/" target="_blank"&gt;http://sappsprod.marinwater.local:8000/equi/&lt;/A&gt;" + SAPID;&lt;/P&gt;&lt;P&gt;// Create a request using a URL that can receive a post.&lt;BR /&gt;//MessageBox.Show(NewURL);&lt;BR /&gt;WebRequest request = WebRequest.Create(urlLink) as HttpWebRequest;&lt;BR /&gt;request.Credentials = CredentialCache.DefaultCredentials;&lt;BR /&gt;request.Method = "GET";&lt;BR /&gt;WebResponse response = request.GetResponse() as HttpWebResponse;&lt;BR /&gt;Stream dataStream = response.GetResponseStream();&lt;BR /&gt;StreamReader reader = new StreamReader(dataStream);&lt;BR /&gt;string responseFromServer = reader.ReadToEnd();&lt;BR /&gt;System.Windows.Forms.MessageBox.Show(responseFromServer);&lt;BR /&gt;JToken outer = JToken.Parse(responseFromServer);&lt;BR /&gt;JArray inner = outer["DATA"].Value&amp;lt;JArray&amp;gt;();&lt;BR /&gt;frmSAPAttributes form = new frmSAPAttributes();&lt;BR /&gt;string strSAPID = "SAPID : " + SAPID;&lt;BR /&gt;&lt;BR /&gt;form.lstAttributes.BeginUpdate();&lt;BR /&gt;form.lstAttributes.Items.Add(strSAPID);&lt;BR /&gt;form.lstAttributes.EndUpdate();&lt;BR /&gt;form.Show();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Would someone please help me understand what's going on?&lt;/P&gt;&lt;P&gt;Thank You!&lt;/P&gt;</description>
      <pubDate>Fri, 04 Feb 2022 17:57:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/addin-button-won-t-populate-windows-form-listbox/m-p/1140868#M7729</guid>
      <dc:creator>MarietteShin</dc:creator>
      <dc:date>2022-02-04T17:57:44Z</dc:date>
    </item>
    <item>
      <title>Re: AddIn Button won't populate Windows Form Listbox with returned string from web request</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/addin-button-won-t-populate-windows-form-listbox/m-p/1141024#M7735</link>
      <description>&lt;P&gt;Not sure why its hanging, could be something with doing UI stuff in a queuedTask. The bigger issue is that it looks like your combo box is a Windows.Forms.ComboBox and while it supposedly possible to use that, Pro AddIn development is supposed to use WPF. Take a look at this video: &lt;A href="https://www.youtube.com/watch?v=ItzVMZZDRGc" target="_blank"&gt;https://www.youtube.com/watch?v=ItzVMZZDRGc&lt;/A&gt; . It does a good job of explaining how to set up the combo box and get it to automatically update when adding stuff.&lt;/P&gt;&lt;P&gt;It's worth it to watch the whole thing, but the relevant part to populating combo boxes starts around 22:00.&lt;/P&gt;&lt;P&gt;Pro AddIns, especially with some sort of UI using WPF and MVVM are a sizeable learning curve jump from ArcMap AddIns and will take a while to get used to, but not too bad after that. Just have to get used to writing considerably more code to do the same thing.&lt;/P&gt;&lt;P&gt;From another newbie.&lt;/P&gt;</description>
      <pubDate>Sun, 06 Feb 2022 03:02:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/addin-button-won-t-populate-windows-form-listbox/m-p/1141024#M7735</guid>
      <dc:creator>BerndtNording</dc:creator>
      <dc:date>2022-02-06T03:02:22Z</dc:date>
    </item>
    <item>
      <title>Re: AddIn Button won't populate Windows Form Listbox with returned string from web request</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/addin-button-won-t-populate-windows-form-listbox/m-p/1141357#M7743</link>
      <description>&lt;P&gt;Thank you very much for your reply, Berndt.&lt;/P&gt;&lt;P&gt;After looking at the video you sent me, I realized that just displaying a list requires use of WPF and a View Model dockpane. I'm trying to find a good existing .NET project for the display of a simple list that I can use to build on. If you know of any, please send my way.&lt;/P&gt;&lt;P&gt;I see that it's a whole new world for ArcObjects now.&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;Mariette&lt;/P&gt;</description>
      <pubDate>Mon, 07 Feb 2022 20:43:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/addin-button-won-t-populate-windows-form-listbox/m-p/1141357#M7743</guid>
      <dc:creator>MarietteShin</dc:creator>
      <dc:date>2022-02-07T20:43:44Z</dc:date>
    </item>
    <item>
      <title>Re: AddIn Button won't populate Windows Form Listbox with returned string from web request</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/addin-button-won-t-populate-windows-form-listbox/m-p/1141402#M7746</link>
      <description>&lt;P&gt;Whole new world - maybe. More like a different planet. The "help" is unfortunately rather fragmented:&lt;/P&gt;&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/2.8/sdk/api-reference/index.html#topic1.html" target="_self"&gt;Reference&lt;/A&gt;&amp;nbsp; The reference for all the Pro objects. For the most part auto-generated and doesn't give you much more than what intellisense does.&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/Esri/arcgis-pro-sdk/wiki/ProSnippets" target="_self"&gt;Snippets&lt;/A&gt;&amp;nbsp; Bits of code to do various things. Very good, but requires a lot of searching through the various categories if you didn't create the SDK and thus don't know what's in all the various SDK assemblies.&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/Esri/arcgis-pro-sdk-community-samples" target="_self"&gt;Samples&lt;/A&gt;&amp;nbsp; Lots of very good samples. Requires some editing in wordpad of the .csproj files if you did not install ArcGIS in the default location.&lt;/P&gt;&lt;P&gt;The one you want to look at is under "Framework" called DockpaneSimple. It has a couple of listboxes. Pay attention to the Bindings in BookmarkDockpane.XAML for the listboxes, and the corresponding properties in BookmarkDockpaneViewModel.cs&amp;nbsp; That app makes a list of Bookmark names, but can just as easily be some text items you get from your WebResponse.&lt;/P&gt;&lt;P&gt;DockPanels don't go away once they are created, so if you want your app to work like a geoprocessing tool and go away once it's done doing it's work, you'll need to add this at the end:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;        DockPane dockPane = FrameworkApplication.DockPaneManager.Find(_dockPaneID);
        if (dockPane != null) { dockPane.IsVisible = false; }&lt;/LI-CODE&gt;&lt;P&gt;You can find what _docPaneID for your app is supposed to be in the Config.DAML for your addin.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Feb 2022 22:07:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/addin-button-won-t-populate-windows-form-listbox/m-p/1141402#M7746</guid>
      <dc:creator>BerndtNording</dc:creator>
      <dc:date>2022-02-07T22:07:19Z</dc:date>
    </item>
    <item>
      <title>Re: AddIn Button won't populate Windows Form Listbox with returned string from web request</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/addin-button-won-t-populate-windows-form-listbox/m-p/1142780#M7759</link>
      <description>&lt;P&gt;Thank you, Berndt!&lt;/P&gt;&lt;P&gt;i have downloaded the community samples and have looked at the DockpaneSimple example you suggested. I am trying to figure out how to use this for my needs. I wish that there was an easier way &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;You have been very helpful, and I really appreciate your time in helping me out.&lt;/P&gt;&lt;P&gt;I think that these samples are as good as it gets, at least for the time being. I think I need to find some WPF snd MVVM trainings...&lt;/P&gt;&lt;P&gt;thanks again.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Feb 2022 18:37:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/addin-button-won-t-populate-windows-form-listbox/m-p/1142780#M7759</guid>
      <dc:creator>MarietteShin</dc:creator>
      <dc:date>2022-02-10T18:37:38Z</dc:date>
    </item>
  </channel>
</rss>

