AutoCompleteBox - SelectedItem design change - source code download

17 December 2008

One piece of feedback that has been recently made clear is that of the community on the AutoCompleteBox's SelectedItem property. Thanks for letting us know that this is important. In this post, I'm providing a fix for this new, and admittedly better, behavior.

The request started on the Silverlight.net forums and then was opened up as a feature request on the CodePlex issue tracker for the toolkit. This is the ideal feedback mechanism since it is easy to track, visible, and the voting mechanism really helps us prioritize our team's work. We actually even synchronize our internal TFS bug database with the CodePlex work items, so it's pretty slick.

As released in November and December, the property was read-only, lending to occassionally annoying use of the control. Master/details displays, typical data-driven forms, and anywhere that you wanted to set this value in code or through a binding would end up running into an exception like this:

Sample exception message from before this design change.

This change was checked into our TFS server yesterday, and will be made available on CodePlex and in the toolkit when we next release. For folks who would like to have this fix immediately, I am making available the changes and the updated AutoCompleteBox.cs file (plus associated unit tests).

With the updated file, when the SelectedItem property is set, the Text will be updated as appropriate to match the item. The CLR setter is not public, and the dependency property can also be updated. Let the celebration commence!

Control & test source download

Download the updated source file:

Updating and building the Microsoft.Windows.Controls.dll file:

  • Download the source package for the December toolkit
  • Overwrite the AutoCompleteBox.cs with the updated source file
  • Rebuild the controls project by opening up the 'Visual Studio 2008 Command Prompt' window, navigating to the Source folder of the extracted download, and typing 'msbuild'

Download the December 2008 release of the Silverlight Toolkit

Important: These downloads do not contain the fix described in this blog post. You'll need to manually overwrite the AutoCompleteBox.cs file and rebuild per the instructions.

Jeff Wilcox is a Software Engineer at Microsoft in the Open Source Programs Office (OSPO), helping Microsoft engineers use, contribute to and release open source at scale.

comments powered by Disqus