Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
235
XamTextEditor, can't update value in TextChanged event handler
posted

When I type into XamTextEditor, I want to modify the text sometimes while typing. What I do now is handle TextChanged event and if text is not correct, I want to set it to something else by doing text="..." inside the handler. The problem is that TextEditor doesn't update the visible text in the editor, although it's  text value has internally changed (when I read a value it's correct). Doing this in WPF's TextBox it works.

How do I do this or is there another way?

 

Best regards

Tomaz

Parents
  • 27093
    posted

    Hello Tomaz,

     

    I have been looking through your case and have found a way for you to achieve your goal. Since the TextChanged event is fired simultaneously as the change takes place, every action you  do inside the event has a chance to take a higher thread priority and be overridden when the NewValue

     is actually applied. You can overcome this by ensuring that your code takes a lower priority using the Dispatcher class like so:

     

    private void xamTextEditor1_TextChanged(object sender, RoutedPropertyChangedEventArgs<string> e)

    {

        if (e.NewValue=="textt")

        {

            Dispatcher.BeginInvoke(new Action(() => { xamTextEditor1.Text= "text"; }), System.Windows.Threading.DispatcherPriority.DataBind, null);

        }

               

    }

     

    Please let me know if you require any further assistance on the matter.

     

    Sincerely,

    Petar Monov

    Developer Support Engineer

    Infragistics Bulgaria

    www.infragistics.com/support

Reply Children