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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:49:36+00:00 2026-05-22T19:49:36+00:00

Scenario: UserControl that has a read-only TextBox and a Button. TextBox.Text is modified and

  • 0

Scenario: UserControl that has a read-only TextBox and a Button. TextBox.Text is modified and updated whenever the Button is pressed.

Problem: TextControl.Text property is bound to UserControl.Message dependency property but does not update when UserControl.Message is modified from within UserControl. However, target does update when INotifyPropertyChanged is implemented.

I don’t actually need to implement INotifyPropertyChanged on a dependency property do I? What am I missing? Please see demonstration code here.

Thanks.

Message Property Declaration

    public static readonly DependencyProperty MessageProperty = 
        DependencyProperty.Register("Message", typeof (string), 
        typeof (TextControl), new FrameworkPropertyMetadata("[WPFApp]" + 
        Environment.NewLine, OnMessageChanged, OnMessageCoerce));

    public string Message
    {
        get { return (string) GetValue(MessageProperty); }
        set { SetValue(MessageProperty, value); }
    }

    private static object OnMessageCoerce(DependencyObject obj, 
        object baseValue)
    {
        return (string) obj.GetValue(MessageProperty) + (string) baseValue;
    }

    private static void OnMessageChanged(DependencyObject d,
        DependencyPropertyChangedEventArgs e)
    {
         // do i need to do this?
         ((TextControl) d).NotifyPropertyChanged("Message");
    }

UserControl abbreviated XAML

<UserControl x:Class="WPFApp.TextControl"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
         mc:Ignorable="d" d:DesignHeight="64" d:DesignWidth="355"
         DataContext="{Binding RelativeSource={RelativeSource Self}}">
<Grid>
    <TextBox Text="{Binding Message, Mode=OneWay}" ... />
    <Button ... />
</Grid>
</UserControl>
  • 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-22T19:49:37+00:00Added an answer on May 22, 2026 at 7:49 pm

    1) No, you don’t have to call NotifyPropertyChanged for DependencyProperties.
    2) Use a relative source for the binding:

    <TextBox Text="{Binding Message, Mode=OneWay,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=UserControl}}" ... />
    

    Additional information:

    To find binding related errors, look in the Visual Studio outut window for binding error messages. They are mostly very clear and lead you quickly to the problem.

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

Sidebar

Related Questions

I have a really basic user control with a button that has an image.
I have a problem regarding getting the path of a user control. The scenario
Scenario: You have an ASP.Net webpage that should display the next image in a
Scenario: Attempting to import many (>100), large(>1M recs) flat-files (csv). Problem: Many records are
Scenario is that we send out thousands of emails through SMTP server. Content is
Scenario: An event is raised in class A that needs to be handled by
Scenario You've got several bug reports all showing the same problem. They're all cryptic
My scenario: I have a background thread that polls for changes and periodically updates
I am currently facing a scenario that I am unsure what is the best
Scenario: I'm trying to intercept paste events inside a textarea/input text, and filter the

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.