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

  • Home
  • SEARCH
  • 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 3491068
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T11:35:33+00:00 2026-05-18T11:35:33+00:00

I have a user control which implements INotifyPropertyChanged and has a property SelectedTopicDescription and

  • 0

I have a user control which implements INotifyPropertyChanged and has a property SelectedTopicDescription and I am trying to bind a textbox Text property to this public property. I know the property is changing however the textbox is not being updated.

I have tried a number of things and I know this should be easy.

I have tried using the following datacontext within the UserControl xaml but it had no effect. I have read about dependency properities but shouldn’t i be able to do this by using INotifyPropertyChanged?

Your help is appreciated.

DataContext=”{Binding RelativeSource={RelativeSource Self}}”

public partial class CodePage : UserControl  ,INotifyPropertyChanged{

    private string _selectedTopicDescription = string.Empty;
    public string SelectedTopicDescription {
        get { return _selectedTopicDescription; }
        set { 
            _selectedTopicDescription = value; 
            OnPropertyChanged("SelectedTopicDescription"); 
        }
    }

    public event PropertyChangedEventHandler PropertyChanged;
    protected virtual void OnPropertyChanged(string property) {
        PropertyChangedEventHandler ph = this.PropertyChanged;
        if (ph != null)
            ph(this, new PropertyChangedEventArgs(property));
    }

…

The textbox is..

Width=”200″ Margin=”141,142,0,153″
Text=”{Binding SelectedTopicDescription}”
HorizontalAlignment=”Left”>

  • 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-18T11:35:34+00:00Added an answer on May 18, 2026 at 11:35 am

    It’s probably not a good idea to fiddle around with DataContext when binding elements in a Usercontrol with properties of the that UserControl. Instead direct the binding to the UserControl via the ElementName property of Binding, like this:-

    <TextBox Text="{Binding Parent.SelectedTopicDescription, ElementName=LayoutRoot, Mode=TwoWay}" />
    

    This uses the fact that the Content element in the user control is has the name “LayoutRoot” and that in turn being a FrameworkElement has a Parent property which will be the UserControl.

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

Sidebar

Related Questions

I have user control named DateTimeUC which has two textboxes on its markup: <asp:TextBox
I have a user control which contains a textbox. I have a class called
I have a ASP.NET user control which hosts a 'HtmlImage'. The src attribute is
I have UserControl which contains a TextBox and a Button control. The Button opens
I have a user control that is pretty basic. It contains several TextBox controls,
I have a user control where the XAML of the control can bind to
[Original] I have a ListBox which has its ItemsSource (this is done in the
I have a web user control which call some methods of an interface. Four
I have created a user control in Silverlight which basically animates the size of
I have a class which implements UserControl. In .NET 2005, a Dispose method is

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.