Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 201397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T17:11:44+00:00 2026-05-11T17:11:44+00:00

I have a TextBox that is bound to a Text-property on an Entity-object. I’d

  • 0

I have a TextBox that is bound to a Text-property on an Entity-object.
I’d like to be able to re-format the text the user enters in some circumstances – e.g. if the user enters “2/4” (a fraction) – I’d like to change that to “1/2”.

Via the “set-part” of the Text-property, I can change the value on the Entity-object, but that doesn’t appear in the TextBox – it still reads “2/4”?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T17:11:44+00:00Added an answer on May 11, 2026 at 5:11 pm

    The reason for this is that the binding system in WPF is “intelligent” and when you change the value in the TextBox it assumes that the PropertyChanged event will fire for that property and ignores it.

    You can force the TextBox to refresh its bindings by calling:

    textBox.GetBindingExpression(TextBox.TextProperty).UpdateTarget();
    

    but the difficulty is finding a good place to hook this in. Obviously your data object can’t do it since it has no reference to the TextBox instance. You could do it in the window that holds the TextBox by linking it to the PropertyChanged event handler of the data object, but that doesn’t feel very clean.

    I’ll edit this response if I think of a better solution, but at least this explains the reason that the binding isn’t working.


    Aha! Changing the binding to IsAsync=true:

    <TextBox x:Name="textBox" Text="{Binding Path=TestData, IsAsync=true}"/>
    

    Appears to alter the behaviour so that it does pay attention to the PropertyChanged event when it’s fired by the setter.


    As an addendum (32 months later) this behaviour has been changed in .NET 4 and you won’t need the IsAsync anymore.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a UserControl that contains a TextBox. The TextBox.Text property is data-bound and
I have a TextBox bound to a ViewModel's Text property with the following setup:
I have a WPF TextBox , with the Text property bound to an int
I have a TextBox control on my form that is bound to a property
I have a textbox that I would like for only numbers. But if I
I have a textbox that i am binding to the viewmodel's string property. The
I have a TextBox that has the TextChanged event set declaratively. In some cases,
I would like to have a TextBox that supports AutoComplete and lets users type
I have an HTML textbox that contains some SQL code that I need executed.
I have a few views that each have several XAML TextBox instances. The Text

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.