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 7894157
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:19:20+00:00 2026-06-03T07:19:20+00:00

I have a two way binding on a string dependency property to the Text

  • 0

I have a two way binding on a string dependency property to the Text of a TextBox.

The binding looks like this:

Text="{Binding MyValue, Mode=TwoWay}"

I have some code that fires in OnKeyUp (in an attached property) that sets MyValue. But rather than taking my value and applying it to the Text property, it is going the other way around.

Here are the sequence of events:

  1. The user enters a string of text that looks like this: 0299900650
  2. The user presses enter.
  3. In my on key up I set MyValue to 2999 and move to the focus to the next field.
  4. The setter for MyValue fires and does a NotifiyPropertyChanged with 2999
  5. The LostFocus fires.
  6. The setter for MyValue fires and does a NotifiyPropertyChanged with 0299900650.

It seems to me that my value is not making it back to “TextBox.Text” somehow. When I loose focus the TextBox is updating the value of the string with what it has in the Text property (the unchanged value because my change did not get back.)

Is there some WPF magic I am not aware of here?

NOTE: I have double checked my bindings. (Besides they work from the UI so I imagine they are correct going to the UI.)

NOTE II: When I say the “user enters a string”, it is really a scanned barcode. But since I am using a keyboard wedge, it is as if it was typed in. (However, the whole point of setting the value is because I am doing something different if the user scans as apposed to typing.)

UPDATE: I found this was due to another property having a side effect. I was able to fix the problem.

  • 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-06-03T07:19:21+00:00Added an answer on June 3, 2026 at 7:19 am

    You simply jump into the concurency conflict on WPF binding messaging.
    To prove that, do the following:

    • remove your OnKeyUp even handler

    and do the same you did. On Enter click binding mechanism fires and sets your code behind property.

    In case when you make on KeyUp, you new value 2999 is surpressed by the binding after.

    To manage this correctly make use of Converter and get rid of OnKeyDown even subscription.

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

Sidebar

Related Questions

I cannot get a two-way bind in WPF to work. I have a string
In my Silverlight prjoect I am creating a simple two-way binding in code: This
Matt Hamilton told me an interesting fact about WPF: binding in two way mode
I need to have two way communication between threads in Tcl and all I
I have a situation where I want a Java client to have a two-way
I have two entity classes annotated in the following way @Entity class A {
I have simple issue setting a two-way databinding of a checkbox in Silverlight 3.0.
I have implement a scenario which involves two way communication between child and parent
I have two spreadsheets... when one gets modified in a certain way I want
I have two keyboards connected to my PC, is there any way to know

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.