<?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 SearchTextBox and inconsistent behaviour with SuggestSource in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/searchtextbox-and-inconsistent-behaviour-with/m-p/1171021#M8096</link>
    <description>&lt;P&gt;I have an ESRI control, SearchTextBox on my dockpane which I intend to show a suggested list of known authors in autocomplete dropdown that appears underneath the control - this is inbuilt functionality. You have to populate the SuggestionSource with an ObservableCollection of type objects.&lt;/P&gt;&lt;P&gt;In my case I am passing a list of strings (after the user types at least 2 letters). I assign my list of strings to ObservableCollection&amp;lt;object&amp;gt; AuthorList which is bound in XAML:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt; &amp;lt;controls:SearchTextBox 
    x:Name="AuthorTextBox" SuggestionListMax="15"
    SuggestionSource="{Binding AuthorList}" ShowMagnifier="False" 
    InfoText="Author" SearchMode="Manual" 
    TextChanged="AuthorTextBox_OnTextChanged"&amp;gt;
&amp;lt;/controls:SearchTextBox&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As you can see this works to some extent (see below) - but it does not populate on every key press - it is very intermittent - even if you wait 1 minute! between each key press - sometimes nothing populates, then you can press delete and lose focus and click back, then add some letters and it populates, but it is very erratic in behaviour and this is very frustrating for me.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Vidar_0-1651748149656.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/40660i20E5CD7CAF19F164/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Vidar_0-1651748149656.png" alt="Vidar_0-1651748149656.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;So I am typing "Jones" - and I debug and I can clearly see that the list has been cleared and it is about to accept 15 new entries,&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Vidar_1-1651748378553.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/40661i5E80C3C4644BC84A/image-size/large?v=v2&amp;amp;px=999" role="button" title="Vidar_1-1651748378553.png" alt="Vidar_1-1651748378553.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;however this seems to be ignored. When I go back to the application the control looks like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Vidar_2-1651748597840.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/40664i4B942893D2BC9989/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Vidar_2-1651748597840.png" alt="Vidar_2-1651748597840.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my code on the text changed event - it is retrieving a list of 15 authors in sub second speed, it is very fast.&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;private async void AuthorTextBox_OnTextChanged(object sender, TextChangedEventArgs e)
{
	if (AuthorTextBox.Text.Length &amp;gt; 2)
	{
		try
		{
			UriBuilder uriBuilder = new UriBuilder
			{
				Scheme = "https",
				Host = "localhost",
				Path = "service/AuthorBasic/1",
				Port = 7269,
				Query = $"name={AuthorTextBox.Text}"
			};

			var response = await CitationSearchVM.Client.GetAsync(uriBuilder.Uri);

			if (response.IsSuccessStatusCode == false)
			{
				Log.Error("FAIL: " + response.StatusCode);
			}
			else
			{
				string jsonText = await response.Content.ReadAsStringAsync();
				AuthorBasicResponse authorResponse = JsonConvert.DeserializeObject&amp;lt;AuthorBasicResponse&amp;gt;(jsonText);
				Module1.CitationSearchVM.AuthorList.Clear();

				Module1.CitationSearchVM.AuthorList.AddRange(authorResponse.Authors);
			}
		}
		catch (Exception ex)
		{
			Log.Error(ex);
		}
	}
}&lt;/LI-CODE&gt;&lt;P&gt;I don't know whether its some race condition or something I must be subtlety doing wrong.&lt;/P&gt;&lt;P&gt;If anyone can help it would be much appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 05 May 2022 11:08:53 GMT</pubDate>
    <dc:creator>Vidar</dc:creator>
    <dc:date>2022-05-05T11:08:53Z</dc:date>
    <item>
      <title>SearchTextBox and inconsistent behaviour with SuggestSource</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/searchtextbox-and-inconsistent-behaviour-with/m-p/1171021#M8096</link>
      <description>&lt;P&gt;I have an ESRI control, SearchTextBox on my dockpane which I intend to show a suggested list of known authors in autocomplete dropdown that appears underneath the control - this is inbuilt functionality. You have to populate the SuggestionSource with an ObservableCollection of type objects.&lt;/P&gt;&lt;P&gt;In my case I am passing a list of strings (after the user types at least 2 letters). I assign my list of strings to ObservableCollection&amp;lt;object&amp;gt; AuthorList which is bound in XAML:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt; &amp;lt;controls:SearchTextBox 
    x:Name="AuthorTextBox" SuggestionListMax="15"
    SuggestionSource="{Binding AuthorList}" ShowMagnifier="False" 
    InfoText="Author" SearchMode="Manual" 
    TextChanged="AuthorTextBox_OnTextChanged"&amp;gt;
&amp;lt;/controls:SearchTextBox&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As you can see this works to some extent (see below) - but it does not populate on every key press - it is very intermittent - even if you wait 1 minute! between each key press - sometimes nothing populates, then you can press delete and lose focus and click back, then add some letters and it populates, but it is very erratic in behaviour and this is very frustrating for me.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Vidar_0-1651748149656.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/40660i20E5CD7CAF19F164/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Vidar_0-1651748149656.png" alt="Vidar_0-1651748149656.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;So I am typing "Jones" - and I debug and I can clearly see that the list has been cleared and it is about to accept 15 new entries,&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Vidar_1-1651748378553.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/40661i5E80C3C4644BC84A/image-size/large?v=v2&amp;amp;px=999" role="button" title="Vidar_1-1651748378553.png" alt="Vidar_1-1651748378553.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;however this seems to be ignored. When I go back to the application the control looks like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Vidar_2-1651748597840.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/40664i4B942893D2BC9989/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Vidar_2-1651748597840.png" alt="Vidar_2-1651748597840.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my code on the text changed event - it is retrieving a list of 15 authors in sub second speed, it is very fast.&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;private async void AuthorTextBox_OnTextChanged(object sender, TextChangedEventArgs e)
{
	if (AuthorTextBox.Text.Length &amp;gt; 2)
	{
		try
		{
			UriBuilder uriBuilder = new UriBuilder
			{
				Scheme = "https",
				Host = "localhost",
				Path = "service/AuthorBasic/1",
				Port = 7269,
				Query = $"name={AuthorTextBox.Text}"
			};

			var response = await CitationSearchVM.Client.GetAsync(uriBuilder.Uri);

			if (response.IsSuccessStatusCode == false)
			{
				Log.Error("FAIL: " + response.StatusCode);
			}
			else
			{
				string jsonText = await response.Content.ReadAsStringAsync();
				AuthorBasicResponse authorResponse = JsonConvert.DeserializeObject&amp;lt;AuthorBasicResponse&amp;gt;(jsonText);
				Module1.CitationSearchVM.AuthorList.Clear();

				Module1.CitationSearchVM.AuthorList.AddRange(authorResponse.Authors);
			}
		}
		catch (Exception ex)
		{
			Log.Error(ex);
		}
	}
}&lt;/LI-CODE&gt;&lt;P&gt;I don't know whether its some race condition or something I must be subtlety doing wrong.&lt;/P&gt;&lt;P&gt;If anyone can help it would be much appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 May 2022 11:08:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/searchtextbox-and-inconsistent-behaviour-with/m-p/1171021#M8096</guid>
      <dc:creator>Vidar</dc:creator>
      <dc:date>2022-05-05T11:08:53Z</dc:date>
    </item>
  </channel>
</rss>

