<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Auto Complete for Textboxes in WPF</title>
	<atom:link href="http://www.lazarciuc.ro/ioan/2008/06/01/auto-complete-for-textboxes-in-wpf/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.lazarciuc.ro/ioan/2008/06/01/auto-complete-for-textboxes-in-wpf/</link>
	<description>I program, therefore I exist.</description>
	<lastBuildDate>Mon, 30 Aug 2010 23:23:55 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: cretz</title>
		<link>http://www.lazarciuc.ro/ioan/2008/06/01/auto-complete-for-textboxes-in-wpf/comment-page-1/#comment-148</link>
		<dc:creator>cretz</dc:creator>
		<pubDate>Thu, 18 Mar 2010 20:48:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.lazarciuc.ro/ioan/2008/06/01/auto-complete-for-textboxes-in-wpf/#comment-148</guid>
		<description>Sorry people, my blog engine failed to report the new comments that were awaiting moderation. I will try to answer each of you in the coming days.</description>
		<content:encoded><![CDATA[<p>Sorry people, my blog engine failed to report the new comments that were awaiting moderation. I will try to answer each of you in the coming days.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eduardo Molteni</title>
		<link>http://www.lazarciuc.ro/ioan/2008/06/01/auto-complete-for-textboxes-in-wpf/comment-page-1/#comment-138</link>
		<dc:creator>Eduardo Molteni</dc:creator>
		<pubDate>Wed, 03 Feb 2010 10:40:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.lazarciuc.ro/ioan/2008/06/01/auto-complete-for-textboxes-in-wpf/#comment-138</guid>
		<description>If you add  &lt;code&gt;StaysOpen=&quot;False&quot;&lt;/code&gt; to the popup, it will automatically close if the user clicks elsewhere.</description>
		<content:encoded><![CDATA[<p>If you add  <code>StaysOpen="False"</code> to the popup, it will automatically close if the user clicks elsewhere.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nav</title>
		<link>http://www.lazarciuc.ro/ioan/2008/06/01/auto-complete-for-textboxes-in-wpf/comment-page-1/#comment-134</link>
		<dc:creator>Nav</dc:creator>
		<pubDate>Tue, 29 Dec 2009 19:02:33 +0000</pubDate>
		<guid isPermaLink="false">http://www.lazarciuc.ro/ioan/2008/06/01/auto-complete-for-textboxes-in-wpf/#comment-134</guid>
		<description>For some reason I am not able to navigate the the list using up, down arrow keys (I tried all three versions). This is what I tried, I run AutoCompleteTest and then enter val, which opens up the popup and then shows 10 entries but I cannot navigate through them using the keys</description>
		<content:encoded><![CDATA[<p>For some reason I am not able to navigate the the list using up, down arrow keys (I tried all three versions). This is what I tried, I run AutoCompleteTest and then enter val, which opens up the popup and then shows 10 entries but I cannot navigate through them using the keys</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cretz</title>
		<link>http://www.lazarciuc.ro/ioan/2008/06/01/auto-complete-for-textboxes-in-wpf/comment-page-1/#comment-113</link>
		<dc:creator>cretz</dc:creator>
		<pubDate>Sat, 29 Aug 2009 10:39:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.lazarciuc.ro/ioan/2008/06/01/auto-complete-for-textboxes-in-wpf/#comment-113</guid>
		<description>The Popup control used internally does not do automatic tracking of the target (because it was not designed to). To detect changes in the parent&#039;s position, you would have to respond to the TargetControl&#039;s LayoutChanged event and close-open the popup.
This would however seriously damage the responsiveness of the control. A delay timer should be used for the actual close,open action, and repositioning should only occur once every X milliseconds (X needs to be determined by trial and error).
Another thing worth mentioning is that the LayoutChanged event occurs even if the resulting position of the target remains unchanged. This allows for further improvement by keeping the screen coordinates of the target control (obtained using the PointToScreen method) and only resetting the popup when those coordinates change.</description>
		<content:encoded><![CDATA[<p>The Popup control used internally does not do automatic tracking of the target (because it was not designed to). To detect changes in the parent&#8217;s position, you would have to respond to the TargetControl&#8217;s LayoutChanged event and close-open the popup.<br />
This would however seriously damage the responsiveness of the control. A delay timer should be used for the actual close,open action, and repositioning should only occur once every X milliseconds (X needs to be determined by trial and error).<br />
Another thing worth mentioning is that the LayoutChanged event occurs even if the resulting position of the target remains unchanged. This allows for further improvement by keeping the screen coordinates of the target control (obtained using the PointToScreen method) and only resetting the popup when those coordinates change.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Harry Jennerway</title>
		<link>http://www.lazarciuc.ro/ioan/2008/06/01/auto-complete-for-textboxes-in-wpf/comment-page-1/#comment-112</link>
		<dc:creator>Harry Jennerway</dc:creator>
		<pubDate>Sat, 29 Aug 2009 09:49:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.lazarciuc.ro/ioan/2008/06/01/auto-complete-for-textboxes-in-wpf/#comment-112</guid>
		<description>One thing I&#039;ve noticed is that the list does not close if the window is moved while the list is open. Is there any way to get it to closed, I&#039;ve looked at a few of the focus events but none seem to be fired if you click the title bar or elsewhere outside of the textbox.</description>
		<content:encoded><![CDATA[<p>One thing I&#8217;ve noticed is that the list does not close if the window is moved while the list is open. Is there any way to get it to closed, I&#8217;ve looked at a few of the focus events but none seem to be fired if you click the title bar or elsewhere outside of the textbox.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Harry Jennerway</title>
		<link>http://www.lazarciuc.ro/ioan/2008/06/01/auto-complete-for-textboxes-in-wpf/comment-page-1/#comment-111</link>
		<dc:creator>Harry Jennerway</dc:creator>
		<pubDate>Thu, 27 Aug 2009 12:58:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.lazarciuc.ro/ioan/2008/06/01/auto-complete-for-textboxes-in-wpf/#comment-111</guid>
		<description>One thing I thought this lacked (which I added), was an ItemsSource property. 

Also, I found the popup menu to be a tad buggy and would sometimes be shown even though there were no matches. In the suggest method I fixed it (though it may have been because of my Style for popup.), by changing checking the count:
  if(lstBox.Items.Count &gt; 0) {
      lstBox.SelectedIndex = 0;
      pop.VerticalOffset = TargetControl.ActualHeight;
      pop.IsOpen = true;
  }</description>
		<content:encoded><![CDATA[<p>One thing I thought this lacked (which I added), was an ItemsSource property. </p>
<p>Also, I found the popup menu to be a tad buggy and would sometimes be shown even though there were no matches. In the suggest method I fixed it (though it may have been because of my Style for popup.), by changing checking the count:<br />
  if(lstBox.Items.Count &gt; 0) {<br />
      lstBox.SelectedIndex = 0;<br />
      pop.VerticalOffset = TargetControl.ActualHeight;<br />
      pop.IsOpen = true;<br />
  }</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dan</title>
		<link>http://www.lazarciuc.ro/ioan/2008/06/01/auto-complete-for-textboxes-in-wpf/comment-page-1/#comment-104</link>
		<dc:creator>Dan</dc:creator>
		<pubDate>Fri, 31 Jul 2009 22:57:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.lazarciuc.ro/ioan/2008/06/01/auto-complete-for-textboxes-in-wpf/#comment-104</guid>
		<description>I completely agree with the last post: Excellent component, just what I was looking for and much better than anything else I could find -- except...

If the search routine takes a while (say, searching a large database), then it can get bogged down running on every keystroke.  I added a DelayMilliseconds property and if set to something greater than zero (300 - 500ms works well), then the search won&#039;t occur until the user pauses their typing.  This is certainly not my original idea, but I thought it would work well combined with your code.  Here&#039;s the modified code:
        
//I split up the Suggest method as follows:

        private delegate void Suggest2Del();
        private System.Timers.Timer delayTimer;

        private int delayMilliseconds;
        public int DelayMilliseconds
        {
            get { return delayMilliseconds; }
            set { delayMilliseconds = value; }
        }

        private void DelayTimerElapsed(object source, System.Timers.ElapsedEventArgs e)
        {
            delayTimer.Stop();
            Dispatcher.BeginInvoke(new Suggest2Del(this.Suggest2));
        }

        private void Suggest()
        {
            // Skip if TargetControl are not defined or if not enough characters typed
            if (TargetControl == null) return;
            if (TargetControl.Text.Length &lt; MinTypedCharacters)
            {
                   pop.IsOpen = false;
                   lstBox.ItemsSource = null;
                   return;
            }
            if (SearchMethod == null) throw new NullReferenceException(”SeachMethod cannot be null.”);

            if (delayMilliseconds &gt; 0)
            {
                   delayTimer.Interval = delayMilliseconds;
                   delayTimer.Start();
            }
            else
                   Suggest2();
        }

        private void Suggest2()
        {
            IEnumerable res = SearchMethod(TargetControl.Text, MaxResults);

            lstBox.ItemsSource = res;
            if (lstBox.Items.Count &gt; 0)
            {
                lstBox.SelectedIndex = 0;
            }

            pop.VerticalOffset = TargetControl.ActualHeight;
            pop.IsOpen = true;
        }

//And added the last 2 lines to the constructor

        public TextBoxAutoCompleteProvider()
        {
            InitializeComponent();
            itemsSelected = false;
            delayTimer = new System.Timers.Timer();
            delayTimer.Elapsed += new System.Timers.ElapsedEventHandler(DelayTimerElapsed);
        }</description>
		<content:encoded><![CDATA[<p>I completely agree with the last post: Excellent component, just what I was looking for and much better than anything else I could find &#8212; except&#8230;</p>
<p>If the search routine takes a while (say, searching a large database), then it can get bogged down running on every keystroke.  I added a DelayMilliseconds property and if set to something greater than zero (300 &#8211; 500ms works well), then the search won&#8217;t occur until the user pauses their typing.  This is certainly not my original idea, but I thought it would work well combined with your code.  Here&#8217;s the modified code:</p>
<p>//I split up the Suggest method as follows:</p>
<p>        private delegate void Suggest2Del();<br />
        private System.Timers.Timer delayTimer;</p>
<p>        private int delayMilliseconds;<br />
        public int DelayMilliseconds<br />
        {<br />
            get { return delayMilliseconds; }<br />
            set { delayMilliseconds = value; }<br />
        }</p>
<p>        private void DelayTimerElapsed(object source, System.Timers.ElapsedEventArgs e)<br />
        {<br />
            delayTimer.Stop();<br />
            Dispatcher.BeginInvoke(new Suggest2Del(this.Suggest2));<br />
        }</p>
<p>        private void Suggest()<br />
        {<br />
            // Skip if TargetControl are not defined or if not enough characters typed<br />
            if (TargetControl == null) return;<br />
            if (TargetControl.Text.Length < MinTypedCharacters)<br />
            {<br />
                   pop.IsOpen = false;<br />
                   lstBox.ItemsSource = null;<br />
                   return;<br />
            }<br />
            if (SearchMethod == null) throw new NullReferenceException(”SeachMethod cannot be null.”);</p>
<p>            if (delayMilliseconds > 0)<br />
            {<br />
                   delayTimer.Interval = delayMilliseconds;<br />
                   delayTimer.Start();<br />
            }<br />
            else<br />
                   Suggest2();<br />
        }</p>
<p>        private void Suggest2()<br />
        {<br />
            IEnumerable res = SearchMethod(TargetControl.Text, MaxResults);</p>
<p>            lstBox.ItemsSource = res;<br />
            if (lstBox.Items.Count &gt; 0)<br />
            {<br />
                lstBox.SelectedIndex = 0;<br />
            }</p>
<p>            pop.VerticalOffset = TargetControl.ActualHeight;<br />
            pop.IsOpen = true;<br />
        }</p>
<p>//And added the last 2 lines to the constructor</p>
<p>        public TextBoxAutoCompleteProvider()<br />
        {<br />
            InitializeComponent();<br />
            itemsSelected = false;<br />
            delayTimer = new System.Timers.Timer();<br />
            delayTimer.Elapsed += new System.Timers.ElapsedEventHandler(DelayTimerElapsed);<br />
        }</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cretz</title>
		<link>http://www.lazarciuc.ro/ioan/2008/06/01/auto-complete-for-textboxes-in-wpf/comment-page-1/#comment-87</link>
		<dc:creator>cretz</dc:creator>
		<pubDate>Wed, 03 Jun 2009 13:12:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.lazarciuc.ro/ioan/2008/06/01/auto-complete-for-textboxes-in-wpf/#comment-87</guid>
		<description>Happy to help. The code is free to use and modify.</description>
		<content:encoded><![CDATA[<p>Happy to help. The code is free to use and modify.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lotfi</title>
		<link>http://www.lazarciuc.ro/ioan/2008/06/01/auto-complete-for-textboxes-in-wpf/comment-page-1/#comment-86</link>
		<dc:creator>Lotfi</dc:creator>
		<pubDate>Wed, 03 Jun 2009 13:00:03 +0000</pubDate>
		<guid isPermaLink="false">http://www.lazarciuc.ro/ioan/2008/06/01/auto-complete-for-textboxes-in-wpf/#comment-86</guid>
		<description>Excellent component, just what I was looking for !

Just one question, is it free to use?</description>
		<content:encoded><![CDATA[<p>Excellent component, just what I was looking for !</p>
<p>Just one question, is it free to use?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sydney</title>
		<link>http://www.lazarciuc.ro/ioan/2008/06/01/auto-complete-for-textboxes-in-wpf/comment-page-1/#comment-80</link>
		<dc:creator>Sydney</dc:creator>
		<pubDate>Fri, 08 May 2009 19:01:47 +0000</pubDate>
		<guid isPermaLink="false">http://www.lazarciuc.ro/ioan/2008/06/01/auto-complete-for-textboxes-in-wpf/#comment-80</guid>
		<description>This is beautifully done.  I did get the latest source code but still can&#039;t do a mouse selection, and I don&#039;t see any mouse-handling code in there . . .</description>
		<content:encoded><![CDATA[<p>This is beautifully done.  I did get the latest source code but still can&#8217;t do a mouse selection, and I don&#8217;t see any mouse-handling code in there . . .</p>
]]></content:encoded>
	</item>
</channel>
</rss>
