IsEditable="True" TextChanging Event

2 posts, 0 answers
  1. Jon
    Jon avatar
    43 posts
    Member since:
    Jan 2009

    Posted 16 Dec 2008 Link to this post

    I need to make the RadComboBox IsEditable="True", but I still need to know when the Text property is changed.  Searching the forums it looks like there used to be something like:

                RadComboBoxElement comboBoxElement = ((RadComboBoxElement)lbTier1.RootElement.Children[0]);              
                comboBoxElement.TextChanging += new TextChangingEventHandler(comboBoxElement_TextChanging);   

    But this code does not work at all on the Q3 build.  Best I can tell RootElement is not exposed, RadComboBoxElement does not exist and there is no TextChangingEventHandler. 

    Am I missing something?
  2. Valeri Hristov
    Valeri Hristov avatar
    2252 posts

    Posted 17 Dec 2008 Link to this post

    Hi Jon,

    I would strongly recommend using bindings. First, you need a data class that implements INotifyPropertyChanged:

    public class Data : INotifyPropertyChanged
        private string text;
        public string Text 
            get { return text; } 
                text = value; 

        private void HandleTextChanged()
            // Put your Text property changed logic here

        public event PropertyChangedEventHandler PropertyChanged;
        public void OnPropertyChanged(string propertyName)
            if (PropertyChanged != null)
                PropertyChanged(new PropertyChangedEventArgs(propertyName));

    And then you could bind the Text property of the data class to the Text property of the ComboBox:
    <telerikInput:RadComboBox x:Name="Combo1" Text="{Binding Text, Mode=TwoWay}" />

    and in the code-behind of the page:
    Combo1.DataContext = new Data();

    The INotifyPropertyChanged interface implementation is needed to proper two-way binding to the Text property of the combo.

    Generally speaking, the "bindings way" for development is recommended in Silverlight and WPF over the "event handling". In other words, you create a data class that contains the business logic and is independent from the UI, and bind it to the UI, in this case a RadComboBox. You can find more examples demonstrating this technique in my blog posts:

    I hope this helps.

    All the best,
    Valeri Hristov
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top