TextChanged Event

11 posts, 0 answers
  1. lkeel
    lkeel avatar
    115 posts
    Member since:
    Jul 2012

    Posted 15 Jun 2010 Link to this post

    What is the WPF equivalent of the TextChanged event?  I have a RadComboBox that allows editing and when the text changes I need to raise perform some work.

    Thanks in advance,
    Lee
  2. Boyan
    Admin
    Boyan avatar
    758 posts

    Posted 17 Jun 2010 Link to this post

    Hello lkeel,

    In WPF you can use TextBoxBase.TextChanged  event. So just set in xaml:
    TextBoxBase.TextChanged="combo1_TextChanged"

    Let me know if you need more help.

    All the best,
    Boyan
    the Telerik team

    If you want to reduce the size of your Silverlight application, you should check our latest Silverlight tool online - Assembly Minifier (http://blogs.telerik.com/blogs/posts/10-06-10/telerik_assembly_minifier.aspx)

  3. UI for WPF is Visual Studio 2017 Ready
  4. lkeel
    lkeel avatar
    115 posts
    Member since:
    Jul 2012

    Posted 17 Jun 2010 Link to this post

    Apparently I am confused...  I don't see TextBoxBase as a property or method from the RadComboBox.  If my combobox is named "combo" then what code would I use to get to the TextBoxBase?  Is it a straight QI?
  5. Boyan
    Admin
    Boyan avatar
    758 posts

    Posted 22 Jun 2010 Link to this post

    Hi lkeel,

    TextBoxBase.TextChanged  is an attached property. Your XAML will look like this:
    <telerikInput:RadComboBox Height="20" Width="200" x:Name="combo" TextBoxBase.TextChanged="combo_TextChanged" >
    This way you will trigger this event with every symbol you type or every Text change. Then just put the code you want to execute in combo_TextChanged in the code behind.

    Let me know if you have further questions.

    Best wishes,
    Boyan
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  6. Ivano
    Ivano avatar
    39 posts
    Member since:
    Feb 2009

    Posted 27 Jan 2011 Link to this post

    Hi

    how can I do everything in code behind?

    Thanks
  7. Ken
    Ken avatar
    3 posts
    Member since:
    Dec 2011

    Posted 30 May 2012 Link to this post

    Something like this?

    this.comboBox.AddHandler(TextBoxBase.TextChangedEvent, new RoutedEventHandler((o,e) =>
    {
        var currentText = this.comboBox.Text;
      
        // do something now...
    }));


  8. Boyan
    Admin
    Boyan avatar
    758 posts

    Posted 04 Jun 2012 Link to this post

    Hello,

    Yes this is will do, you can attach to the event in code this way.  If you are having problems making it work, we will be glad to help.

    Kind regards,
    Boyan
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  9. Anna Katrina
    Anna Katrina avatar
    9 posts
    Member since:
    Feb 2013

    Posted 25 Aug 2015 Link to this post

    Hi,

     I have trying to apply the same event on my radcombobox as well but seems like textchangedevent is no longer available

     

    <telerik:RadComboBox x:Name="rcboDocSize" DisplayMemberPath="FontSizeName" IsEditable="True" MaxDropDownHeight="190" Width="70" SelectionChanged="rcboDocSize_SelectionChanged" StaysOpenOnEdit="True" />​

     

    when i typedin it says, The property 'TextChanged' was not found in type 'RadComboBox'. Any help about this?

  10. Nasko
    Admin
    Nasko avatar
    585 posts

    Posted 26 Aug 2015 Link to this post

    Hi Anna,

    RadComboBox does not support TextChanged event by design. However, you have two appraoches that you could use in order to achieve the desired.

    The first one is the proposed by Boyan below to use the TextBoxBase.TextChanged attached property:
    <telerik:RadComboBox x:Name="rcboDocSize" DisplayMemberPath="FontSizeName" IsEditable="True" MaxDropDownHeight="190" Width="70" SelectionChanged="rcboDocSize_SelectionChanged" StaysOpenOnEdit="True"
    TextBoxBase.TextChanged="radComboBox_TextChanged"/>​

    and in code - behind:
    private void radComboBox_TextChanged(object sender, TextChangedEventArgs e)
    {
        //implement custom logic here
    }

    The second approach that you could use to handle to the TextChanged event is to get the TextBox placed inside RadComboBox using the ChildrenOfType method (inside the Loaded event) and handle its TextChanged event:
    private void radComboBox_Loaded(object sender, RoutedEventArgs e)
    {
        var combo = sender as RadComboBox;
        var textBox = combo.ChildrenOfType<TextBox>().FirstOrDefault();
        if(textBox != null)
        {
            textBox.TextChanged += textBox_TextChanged;
        }
    }
     
    void textBox_TextChanged(object sender, TextChangedEventArgs e)
    {
        //implement custom logic
    }

    Hopes this helps.

    Regards,
    Nasko
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  11. Anna Katrina
    Anna Katrina avatar
    9 posts
    Member since:
    Feb 2013

    Posted 26 Aug 2015 in reply to Nasko Link to this post

    Thanks for the reply Nasko..

    I have added the TextBoxBase.TextChanged="radComboBox_TextChanged" however it gives me this error on the xaml file:

     'The attachable property 'TextChanged' was not found in type 'TextBoxBase'

    Am i missing header or something in the xaml?

     

    I have also tried working with the loaded event but it throws me a framework element error..

     Thanks in advance. Your help is very much appreciated.

     

  12. Nasko
    Admin
    Nasko avatar
    585 posts

    Posted 28 Aug 2015 Link to this post

    Hello Anna,

    We tried to reproduce the observed by you error but it seems everything works as expected on our side.

    I am attaching you a sample project that demonstrates the approach with the TextBoxBase.TextChanged attached event - please, check it.

    Hopes this helps.

    Regards,
    Nasko
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top
UI for WPF is Visual Studio 2017 Ready