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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T02:48:44+00:00 2026-05-21T02:48:44+00:00

In my ViewModel, I have a class A with a child property B that

  • 0

In my ViewModel, I have a class “A” with a child property “B” that is also a custom class. Both classes implement INotifyPropertyChanged and B’s PropertyChanged event is hooked up to fire A’s PropertyChanged event (with the correct property name of “B”).

I also have a DependencyProperty “DPB” on my ViewModel that is bound to B in code with a very simple binding (new Binding(“A.B”)).

Now I have three TextBoxes in my view:

  • 1 bound to A.B.C (a property of B)
  • 1 bound directly to A.B
  • 1 bound to DPB

On first run, both A.B and the DPB textboxes show the correct value. But when I change the A.B.C textbox, only the A.B textBox is updated – the DPB textBox is not updated.

I have debugged through all of the PropertyChanged notifying code and they are all hit with the correct values passed.

The problem seems to be that the DependencyProperty (or it’s binding) is not being updated when the PropertyChanged event is fired. Can anyone tell me why or how to change this behaviour?

thank you.

  • 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-21T02:48:44+00:00Added an answer on May 21, 2026 at 2:48 am

    I have bad news for you.

    Inside DependencyObject.SetValue the check is located, which verify if new value equals to old value. So if you are binded to A.B, and changing of A.B.C produces PropertyChanged event for A.B, Binding mechanizm will handle this event and even call DependencyObject.SetValue. But then (due to equality of old and new A.B values) no changes will be applied to DP.

    In order to achieve correct DP fireing, you should create new instance of A.B, that concludes in great headache.

    UPDATED

    You could use Freezable object, which supports notification that it has changed when its property is changed. DependencyObject works with Freezables correctly, so next example does what you need.

    Model classes:

    public class A 
    {
        public A()
        {
            this.B = new B();
        }
        public B B
        {
            get; private set;
        }
    }
    
    public class B : Freezable, INotifyPropertyChanged
    {
        protected override Freezable CreateInstanceCore()
        {
            return new B();
        }
    
        private string _c = "initial string";
        public string C
        {
            get
            {
                return _c;
            }
            set
            {
                this._c = value;
                this.OnPropertyChanged("C");
                this.OnChanged();
            }
        }
    
        public event PropertyChangedEventHandler PropertyChanged;
    
        protected void OnPropertyChanged(string name)
        {
            var safe = this.PropertyChanged;
            if (safe != null)
            {
                safe(this, new PropertyChangedEventArgs(name));
            }
        }
    }
    

    Xaml:

    <StackPanel>
        <TextBox Text="{Binding A.B.C}" />
        <TextBox Text="{Binding MyProperty.C}" />
        <Button Click="Button_Click"/>
    </StackPanel>
    

    Code behind:

    public partial class TextBoxesView : UserControl
    {
        public TextBoxesView()
        {
            InitializeComponent();
    
            this.A = new A();
            this.DataContext = this;
    
            BindingOperations.SetBinding(this, TextBoxesView.MyPropertyProperty, new Binding("A.B"));
        }
    
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            this.A.B.C = DateTime.Now.ToString();
        }
    
        public A A
        {
            get;
            private set;
        }
    
        public B MyProperty
        {
            get
            {
                return (B)this.GetValue(TextBoxesView.MyPropertyProperty);
            }
            set
            {
                this.SetValue(TextBoxesView.MyPropertyProperty, value);
            }
        }
    
        public static readonly DependencyProperty MyPropertyProperty =
            DependencyProperty.Register("MyProperty",
                typeof(B),
                typeof(TextBoxesView),
                new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.None, (d, e) => {  }));
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.