when I try to focus on my "autocompletetextbox" I failed I write autocompletetextbox.focus()
but the cursor still focus in another what should I do or write to enable to write in it or focus?
views:
26answers:
1
A:
I experienced the same thing -- it does not work properly in its current form (I expect you're talking about the AutoCompleteBox that comes with the February 2010 release of WPFToolkit).
I created a subclass:
public class AutoCompleteFocusableBox : AutoCompleteBox
{
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
var textbox = Template.FindName("Text", this) as TextBox;
if(textbox != null) textbox.Focus();
}
}
This sets focus to the actual TextBox
(called "Text") that is part of the default ControlTemplate
.
Jay
2010-08-27 20:02:04
where should I put this class I tried at the class which has the auto complete box but it doesn't work ?
salamonti
2010-08-31 16:03:36
In your XAML you use this instead of `AutoCompleteBox`. So if you have this class in namespace XYZ, you import that namespace in the root of the XAML file, with an alias like xyz and then use <xyz:AutoCompleteFocusableBox Width="500" x:Name="myFocusBox" …>
Jay
2010-08-31 16:16:50
I tried but blend get me an error AutoCompleteFocusableBox doesn't support wpf!!!
salamonti
2010-08-31 17:09:48
Are you in fact using the February 2010 WPFToolkit release? What version of Blend? This works for me in Blend 3. With your project loaded in blend, you should be able to find this control using the search feature in the toolbox, and add it through the GUI just like any other control.
Jay
2010-08-31 18:00:03
thanks so so so much Jay
salamonti
2010-08-31 19:21:26