Posted 17 December 2008 Tweet
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:
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!
Download the updated source file:
Updating and building the Microsoft.Windows.Controls.dll file:
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 Principal Software Engineer at Microsoft in the Open Source Programs Office, helping Microsoft scale to 10,000+ engineers using, contributing to and releasing open source.