SilverlightShow: Using the AutoCompleteBox Comments http://www.silverlightshow.net/ Silverlight articles, Silverlight tutorials, Silverlight videos, Silverlight samples SilverlightShow.net http://www.rssboard.org/rss-specification Argotic Syndication Framework 2008.0.2.0, http://www.codeplex.com/Argotic en-US estoychev@completit.com (Emil Stoychev) Re: Using the AutoCompleteBox <p>In my project i needed an autocomplete of symbols also. For example @,#</p> <p>I am not getting the solution for this. </p> http://www.silverlightshow.net/items/Using-the-AutoCompleteBox.aspx#comment8042 JaspreetSaini http://www.silverlightshow.net/items/Using-the-AutoCompleteBox.aspx Fri, 11 May 2012 09:33:27 GMT Re: Using the AutoCompleteBox <p>I have got a problem here.</p> <p>I am using  "Asynchronous filtering" method to get data from server. The result from server is a DataView with 3 columns - FirstName, LastName, CompanyName.</p> <p>Whatever I am typing in AutoCompleteBox, server searches for that sub-string in all 3 fields i.e. FirstName, LastName, CompanyName.</p> <p>So for example if user searches for 'Microsoft'. Server returns result: John Players, Microsoft and Penny Schindler, Microsoft.</p> <p>It does not display anything as the ValueMemberPath=FirstName and FirstName does not contain the word 'Microsoft'. Is there a way to define multiple Property names in ValueMemberPath or just ignore it and display all data that is returned?</p> http://www.silverlightshow.net/items/Using-the-AutoCompleteBox.aspx#comment7566 koolest http://www.silverlightshow.net/items/Using-the-AutoCompleteBox.aspx Wed, 22 Feb 2012 14:09:14 GMT Re: Using the AutoCompleteBox <p>Thanks a lot Peter. Something we have been looking for. We had inherited from AutoCompleteBox to achieve some of these features. Your article has help us clear a lot of code. </p> http://www.silverlightshow.net/items/Using-the-AutoCompleteBox.aspx#comment7564 koolest http://www.silverlightshow.net/items/Using-the-AutoCompleteBox.aspx Wed, 22 Feb 2012 09:49:10 GMT Re: Using the AutoCompleteBox <p>@LakshmiNarayana, you could extract the TextBox from within the AutoCompleteBox if you'd like. Either search the Visual Tree, or subclass the ACB and expose the TB.</p> <p>Good luck, HTH,<br /> <a href="http://blogs.microsoft.co.il/blogs/shimmy/">Shimmy</a></p> http://www.silverlightshow.net/items/Using-the-AutoCompleteBox.aspx#comment7472 weitzhandler http://www.silverlightshow.net/items/Using-the-AutoCompleteBox.aspx Wed, 01 Feb 2012 14:19:46 GMT Re: Using the AutoCompleteBox <p>Hi,</p> <p>Great Stuff,</p> <p>I have used this in my project.</p> <p>I need selection start property like textbox, But autocomplete box don't have that type of property ?</p> <p><br /> </p> http://www.silverlightshow.net/items/Using-the-AutoCompleteBox.aspx#comment7471 LakshmiNarayana http://www.silverlightshow.net/items/Using-the-AutoCompleteBox.aspx Wed, 01 Feb 2012 08:40:32 GMT Re: Using the AutoCompleteBox <p>Great post.</p> <p>Thanks for the MVVM bonus. That's what I came in for.</p> http://www.silverlightshow.net/items/Using-the-AutoCompleteBox.aspx#comment7435 weitzhandler http://www.silverlightshow.net/items/Using-the-AutoCompleteBox.aspx Tue, 24 Jan 2012 18:13:58 GMT Re: Using the AutoCompleteBox <p>Very great stuff,</p> <p>the asynchronous filtering with a ViewModel sample is exactly what I was looking for. The samples are very very helpful for me.</p> <p>Thanks a lot for sharing your great knowledge.</p> <h4 style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'palatino linotype', 'book antiqua', palatino, serif; color: #024971; line-height: 24px; font-size: 18px; background-color: #ffffff;"></h4> http://www.silverlightshow.net/items/Using-the-AutoCompleteBox.aspx#comment7414 fabxcp http://www.silverlightshow.net/items/Using-the-AutoCompleteBox.aspx Tue, 17 Jan 2012 03:01:47 GMT RE: Using the AutoCompleteBox <p>Just curious, why doesnt the AutoCompleteBox have an option to show the drop down arrow. Many times the user doesnt know which items are in the list. The drop down gives them an idea of what they can type. I have searched all around the internet and havent found a way to do this with the AutoCOmpleteBox, there are custom controls that half way work, but I think this should be a part of this control...maybe it is and I dont know it?</p> http://www.silverlightshow.net/items/Using-the-AutoCompleteBox.aspx#comment6055 Craig http://www.silverlightshow.net/items/Using-the-AutoCompleteBox.aspx Wed, 04 May 2011 19:53:55 GMT RE: Using the AutoCompleteBox <p>Very helpful! The only nice MVVM solution I found on the internet.</p> <p>I my MVVM application a details view is bound to the SelectedItem property of the AutoCompleteBox. But I don't want to receive selection notifications when the user is scrolling through the list of items using the up and down key. Only when the user closes the dropdown I want to update the details view. How can this be done using MVVM and behaviors?</p> <p>Thank you for your help</p> http://www.silverlightshow.net/items/Using-the-AutoCompleteBox.aspx#comment6027 Michel Miranda http://www.silverlightshow.net/items/Using-the-AutoCompleteBox.aspx Sat, 30 Apr 2011 18:12:37 GMT RE: Using the AutoCompleteBox <p>Very helpful! The only nice MVVM solution I found on the internet.</p> <p>I my MVVM application a details view is bound to the SelectedItem property of the AutoCompleteBox. But I don't want to receive selection notifications when the user is scrolling through the list of items using the up and down key. Only when the user closes the dropdown I want to update the details view. How can this be done using MVVM and behaviors?</p> <p>Thank you for your help</p> http://www.silverlightshow.net/items/Using-the-AutoCompleteBox.aspx#comment6026 Michel Miranda http://www.silverlightshow.net/items/Using-the-AutoCompleteBox.aspx Sat, 30 Apr 2011 17:16:33 GMT RE: Using the AutoCompleteBox <p>You need to set up your item template correctly so the included controls bind to properties that exist on your "MyData" class. </p> <p>If you still have problems with that, feel free to contact me directly.</p> http://www.silverlightshow.net/items/Using-the-AutoCompleteBox.aspx#comment5687 Peter Kuhn http://www.silverlightshow.net/items/Using-the-AutoCompleteBox.aspx Fri, 11 Mar 2011 16:01:00 GMT RE: Using the AutoCompleteBox <p>Hi I am hoping you can help me.</p> <p>I am having trouble with one of my Autocomplete boxes.</p> <p>When i download and run your project for the  ItemTemplat the dropdown works perfectly.</p> <p>When I copy all of your work into my application, the drop down behaves starnge.</p> <p>I can get the data populated and the Autocomplete seems to works however the Dropdown box simply displays a list of </p> <p>MyClass.Assets.MyData</p> <p>MyClass.Assets.MyData </p> <p>etc</p> <p> </p> <p>I have scoured to net looking for an answer to this and cant find one, Plaease help</p> <p>MyClass.Assets.MyData</p> <p>MyClass.Assets.MyData</p> http://www.silverlightshow.net/items/Using-the-AutoCompleteBox.aspx#comment5684 Kevin http://www.silverlightshow.net/items/Using-the-AutoCompleteBox.aspx Fri, 11 Mar 2011 14:03:24 GMT RE: Using the AutoCompleteBox <p>Hi Swamy. It works very similar with RIA Services too. The user state is part of the Load method overloads of the domain context there. For example, take this one:</p> <p><a href="http://msdn.microsoft.com/en-us/library/ff422945(v=vs.91).aspx">http://msdn.microsoft.com/en-us/library/ff422945(v=vs.91).aspx</a></p> <p>You can pass in the user state as last argument there.</p> http://www.silverlightshow.net/items/Using-the-AutoCompleteBox.aspx#comment5678 Peter Kuhn http://www.silverlightshow.net/items/Using-the-AutoCompleteBox.aspx Thu, 10 Mar 2011 10:05:27 GMT RE: Using the AutoCompleteBox <p>Great article .. ! Thanks you very much . .you have saved a lot of time for me ..</p> <p>In your example code, you explained MVVM filtering using web service/wcf service. How can I use it RIA. I was looking for the e.UserState in ria services ... no luck till now .. Any inputs on this would be great help.</p> http://www.silverlightshow.net/items/Using-the-AutoCompleteBox.aspx#comment5675 Swamy http://www.silverlightshow.net/items/Using-the-AutoCompleteBox.aspx Thu, 10 Mar 2011 00:54:42 GMT RE: Using the AutoCompleteBox <p>Hi Jim. The System.Windows.Interactivity assembly is part of Expression Blend. If you don't have Blend, you can download the SDK which also contains these dlls here: <a href="http://www.microsoft.com/downloads/en/details.aspx?FamilyID=d197f51a-de07-4edf-9cba-1f1b4a22110d&displaylang=en">Expression Blend 4 SDK</a>.</p> <p>About returning the Id of the record to your VM: you can access the selected data item through the SelectedItem property. If you bind that property to a property of your VM you will have access to that item in your VM (and can then process the Id property of that item too).</p> http://www.silverlightshow.net/items/Using-the-AutoCompleteBox.aspx#comment5629 Peter Kuhn http://www.silverlightshow.net/items/Using-the-AutoCompleteBox.aspx Thu, 03 Mar 2011 01:02:12 GMT RE: Using the AutoCompleteBox <p>Hi Peter,<br /> Thanks or sharing your knowledge.  I am a newbie  in SL develpment.  I want to adopt your idea but I don't know how to implement if the AutoComplete shows the description but I need the Id of the record to be returned to my VM. </p> <p>In addition, I downloaded your  code and tried to run the MVVM one but getting "Sysem.Windos.Intertivity" could not be found.  Can you hlep?</p> <p>Jim</p> http://www.silverlightshow.net/items/Using-the-AutoCompleteBox.aspx#comment5625 Jim http://www.silverlightshow.net/items/Using-the-AutoCompleteBox.aspx Tue, 01 Mar 2011 17:24:37 GMT RE: Using the AutoCompleteBox awesome article , tank u http://www.silverlightshow.net/items/Using-the-AutoCompleteBox.aspx#comment5447 Aghdam http://www.silverlightshow.net/items/Using-the-AutoCompleteBox.aspx Mon, 07 Feb 2011 17:05:27 GMT RE: Using the AutoCompleteBox <p>Hi Mrunal. Thank you for your comment.</p> <p>The problem with your approach most likely is that the text box handles the key down event and your custom event handler is never executed. You can solve this by adding a handler like this in code:</p> <p><br /> </p> <pre style="font-family: consolas;"><span style="color: #2b91af;"></span><div class="reCodeBlock" style="border:1px solid #7f9db9;overflow-y: auto;"><div style="background-color: #ffffff;"><span style="margin-left: 0px !important;"><code style="color: #000000;">KeyEventHandler eventHandler = MyAutoCompleteBox_KeyDown;</code></span></div><div style="background-color: #f8f8f8;"><span style="margin-left: 0px !important;"><code style="color: #000000;">MyAutoCompleteBox.AddHandler(KeyDownEvent, eventHandler, </code><code style="color: #006699; font-weight: bold;">true</code><code style="color: #000000;">);</code></span></div></div></pre> Note the last parameter (true), it is important. In the event handler, you can then e.g. start a service call or similar. <p><br /> </p> <p>Hope this helps.</p> http://www.silverlightshow.net/items/Using-the-AutoCompleteBox.aspx#comment5444 Peter Kuhn http://www.silverlightshow.net/items/Using-the-AutoCompleteBox.aspx Mon, 07 Feb 2011 11:55:57 GMT RE: Using the AutoCompleteBox <p>Great stuff !!!</p> <p>One of my requirement is let the user press the down arrow key initially and that brings out top 100 results. On pressing the down arrow key the execute method is never called. How can i implement this behavior. Thanks much again.</p> <p> </p> <p>Mrunal</p> http://www.silverlightshow.net/items/Using-the-AutoCompleteBox.aspx#comment5443 Mrunal Buch http://www.silverlightshow.net/items/Using-the-AutoCompleteBox.aspx Mon, 07 Feb 2011 07:52:21 GMT