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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T17:27:35+00:00 2026-05-10T17:27:35+00:00

Why is it that when I use a converter in my binding expression in

  • 0

Why is it that when I use a converter in my binding expression in WPF, the value is not updated when the data is updated.

I have a simple Person data model:

class Person : INotifyPropertyChanged {     public string FirstName { get; set; }     public string LastName { get; set; } } 

My binding expression looks like this:

<TextBlock Text='{Binding Converter={StaticResource personNameConverter}' /> 

My converter looks like this:

class PersonNameConverter : IValueConverter {     public object Convert(object value, Type targetType, object parameter, CultureInfo culture)     {         Person p = value as Person;         return p.FirstName + ' ' + p.LastName;     }      public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)     {         throw new NotImplementedException();     } } 

If I bind the data without a converter it works great:

<TextBlock Text='{Binding Path=FirstName}' /> <TextBlock Text='{Binding Path=LastName}' /> 

What am I missing?

EDIT: Just to clarify a few things, both Joel and Alan are correct regarding the INotifyPropertyChanged interface that needs to be implemented. In reality I do actually implement it but it still doesn’t work.

I can’t use multiple TextBlock elements because I’m trying to bind the Window Title to the full name, and the Window Title does not take a template.

Finally, it is an option to add a compound property ‘FullName’ and bind to it, but I’m still wondering why updating does not happen when the binding uses a converter. Even when I put a break point in the converter code, the debugger just doesn’t get there when an update is done to the underlying data 🙁

Thanks, Uri

  • 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. 2026-05-10T17:27:36+00:00Added an answer on May 10, 2026 at 5:27 pm

    (see edits below; latest: #2)

    It isn’t updating because your Person object is not capable of notifying anything that the value of FirstName or LastName has changed. See this Question.

    And here’s how you implement INotifyPropertyChanged. (Updated, see Edit 2)

    using System.ComponentModel;  class Person : INotifyPropertyChanged {     public event PropertyChangedEventHandler PropertyChanged;      string _firstname;     public string FirstName {         get {             return _firstname;         }         set {             _firstname = value;             onPropertyChanged( 'FirstName', 'FullName' );         }     }      string _lastname;     public string LastName {         get {             return _lastname;         }         set {             _lastname = value;             onPropertyChanged( 'LastName', 'FullName' );         }     }      public string FullName {         get {             return _firstname + ' ' + _lastname;         }     }      void onPropertyChanged( params string[] propertyNames ) {         PropertyChangedEventHandler handler = PropertyChanged;          if ( handler != null ) {             foreach ( var pn in propertyNames ) {                 handler( this, new PropertyChangedEventArgs( pn ) );             }         }     } } 

    Edit 1

    Actually, since you’re after the first name and last name updating, and Path=FirstName and such works just fine, I don’t think you’ll need the converter at all. Multiple TextBlocks are just as valid, and can actually work better when you’re localizing to a right-to-left language.

    Edit 2

    I’ve figured it out. It’s not being notified that the properties have updated because it is binding to the object itself, not one of those properties. Even when I made Person a DependencyObject and made FirstName and LastName DependencyProperties, it wouldn’t update.

    You will have to use a FullName property, and I’ve update the code of the Person class above to reflect that. Then you can bind the Title. (Note: I’ve set the Person object as the Window‘s DataContext.)

    Title='{Binding Path=FullName, Mode=OneWay}' 

    If you’re editing the names in a TextBox and want the name changed reflected immediately instead of when the TextBox loses focus, you can do this:

    <TextBox Name='FirstNameEdit'     Text='{Binding Path=FirstName, UpdateSourceTrigger=PropertyChanged}' /> 

    I know you didn’t want to use a FullName property, but anything that would accomplish what you want would probably be a bit of a Rube Goldberg device. Such as implementing INotifyPropertyChanged and a Person property on the Window class itself, having the Window listen on the PropertyChanged event in order to fire the Window‘s PropertyChanged event, and using a relative binding like the following. You’d also have set the Person property before InitializeComponent() or fire PropertyChanged after setting the Person property so that it shows up, of course. (Otherwise it will be null during InitializeComponent() and needs to know when it’s a Person.)

    <Window.Resources>     <loc:PersonNameConverter         x:Key='conv' /> </Window.Resources> <Window.Title>     <Binding         RelativeSource='{RelativeSource Self}'         Converter='{StaticResource conv}'         Path='Person'         Mode='OneWay' /> </Window.Title> 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i read that i can use data converters in binding like ... <TextBlock Text={Binding
We have many projects that use a common base of shared components (dlls). Currently
I have many sites that use the same root category of the Main Site.
Seems that requirements on safety do not seem to like systems that use AI
I have a number of tables that use the trigger/sequence column to simulate auto_increment
We have a number of projects that use the same and/or similar package names.
I have two unrelated processes that use .NET assemblies as plugins. However, either process
Is it possible to make efficient queries that use the complete regular expression feature
I have a problem with a databinding in WPF. When I try to use
I have a custom converter that has a DefaultText property. All my converter does

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.