I am writing a small wrapper for WPF’s ComboBox and want to hook up (optionally) a delegate that filters the list of items, based on what the user has typed already into the text box portion of the control.
I have achieved this with the help of Mole and the FindName method on the Template object.
TextBox input = ((TextBox)comboBox1.Template.FindName("PART_EditableTextBox",comboBox1));
input.TextChanged += new TextChangedEventHandler(input_TextChanged);
FindName allows us to walk across a templated control and search for a child element by the name we pass in. This allows us to get at some of the innards for some of the existing controls and, in my case as above, attach to events or check properties and the like.
No comments:
Post a Comment