Silverlight 5 + AutoCompleteBox = Bug

后端 未结 1 1128
夕颜
夕颜 2020-12-11 20:34

Just installed SL5 and the toolkit, that were released few days ago.
The bug happens when you set the Text property of the AutoCompleteBox to string.Empty. It causes the

相关标签:
1条回答
  • 2020-12-11 21:20

    I found a workaround for this strange behavior. You need a control derived from AutoCompleteBox and overrride OnApplyTemplate method to find inner TextBox of AutoCompleteBox.

    When inner TextBox TextChanged event fires you need to fire TextChanged event of AutoCompleteBox control manually.

    public class CustomAutoComplete : AutoCompleteBox
    {
        TextBox mytext;
    
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
            mytext = GetTemplateChild("Text") as TextBox;
            mytext.TextChanged += new System.Windows.Controls.TextChangedEventHandler(mytext_TextChanged);
        }
    
        void mytext_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e)
        {
            this.Text = mytext.Text;
            OnTextChanged(new RoutedEventArgs());
        }
    }
    
    0 讨论(0)
提交回复
热议问题