Saturday, October 25, 2008
Previously, my adorner only supports TextBox, RichTextBox and PasswordBox. I found it limiting, as there are so many controls out there that supports editing text. One such case is the ComboBox with the IsEditable property set to true. After trying to add a new code brunch to support the case of ComboBox, I bumped into a wall. The IsFocused property of ComboBox is not reporting the right thing! It reports not focused even with my cursor blinking inside the ComboBox. On examining the visual tree, I found the culprit - the TextBox in the ComboBox is having the focus, not the ComboBox itself. Solution? Hunt for this TextBox! So here comes an updated adorner that searches the visual tree for a TextBox if the attached property is placed on a control other than a TextBox, RichTextBox or PasswordBox. Turned out to be more powerful than originally planned =). One more feature improvement is to have the option not to hide the placeholder text even if the control have the focus (set HideOnFocus to false). This allows you to focus on the control when the application start up and still have the prompt there to tell your user what to do. Miles of code coming your way, watch out!