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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:03:03+00:00 2026-05-31T23:03:03+00:00

While debugging a problem in a WPF application, I have noticed that the TwoWay

  • 0

While debugging a problem in a WPF application, I have noticed that the TwoWay data binding does not seem to be symmetrical. Here is an example:

<Window x:Class="ConverterTest.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
        xmlns:local="clr-namespace:ConverterTest"
        Title="MainWindow" Height="350" Width="525">
    <Window.Resources>
        <local:TextConverter x:Key="textConverter"/>
    </Window.Resources>
    <Grid>
        <TextBox x:Name="txt1" Height="24" Margin="0" VerticalAlignment="Top"/>
        <TextBox x:Name="txt2" Height="24" Margin="0,40,0,0"  VerticalAlignment="Top"
                 Text="{Binding ElementName=txt1, Path=Text, 
                        Mode=TwoWay,
                        UpdateSourceTrigger=PropertyChanged, 
                        Converter={StaticResource textConverter}}"/>
    </Grid>
</Window>

The converter looks like this:

public class TextConverter : IValueConverter
{
    #region IValueConverter Members

    public object Convert(object value, System.Type targetType,
         object parameter, System.Globalization.CultureInfo culture)
    {
        return value.ToString().ToUpper();
    }

    public object ConvertBack(object value, System.Type targetType, 
         object parameter, System.Globalization.CultureInfo culture)
    {
        return value.ToString().ToLower();
    }

    #endregion
}

When editing inside txt1, only Convert() is called; but when editing inside txt2, first ConvertBack() and then Convert() is called.

In other words, TwoWay binding seems to work like this:

  • When the source property is updated, the target property is updated.
  • When the target property is updated, first the source property is updated, and then the target property is updated again.

The MSDN documentation merely says:

Causes changes to either the source property or the target property to automatically update the other.

From that sentence, I would have expected the following behavior:

  • When the source property is updated, the target property is updated.
  • When the target property is updated, the source property is updated.

Is there any way to achieve this symmetrical behavior (purely in XAML, without C# programming)?

EDIT: I just have discovered that in WPF 3.5, TwoWay bindings work symmetrical. In WPF 4.0, however, the behavior has changed (as described above).

  • 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-31T23:03:04+00:00Added an answer on May 31, 2026 at 11:03 pm

    Well, entirely symmetrical cannot be achieved because:

    • When the source is updated, the control just has to show the new value, period. Nothing fancy happens.
    • When the target is updated, before it is written to the source, the change of value can be canceled at a ridiculous amount of places.

    For example: validation.

    When the source is updated, say, from code, it passed all validation (unless you forgot to check, but that’s another problem). The control just displays the new value.

    When the target is updated, the value is first converted back in the converter to be manipulable, then coerced, validated and then at last, the source is set.

    But as you see, the value could have been modified between the target and the source, so the value is converted again, and finally displayed.

    Bonus: to understand where and in which order the value can change, see Dependency Property Value Precedence.

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

Sidebar

Related Questions

While debugging crash in a multithreaded application I finally located the problem in this
While debugging an issue with our system, I have discovered a thread contention that
While debugging jQuery apps that use AJAX, I often have the need to see
I have encountered an error while debugging a VB.Net application in Visual Studio 2008.
I get this problem very often while debugging a ASP.Net MVC(3) application. I found
While debugging a client app that uses a Google backend, I have added some
While debugging a postback problem with a DropDownList within a Repeater I discovered that
facing the issue while debugging String.hashCode() line: not available i have refereed this ,
I noticed while debugging some Javascript that an extra argument that I was passing
While debugging a .NET Framework 3.5, WinForms application I spotted some Worker Threads without

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.