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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T04:19:02+00:00 2026-05-18T04:19:02+00:00

I am pretty sure I am doing something dreadfully wrong, but can’t figure it

  • 0

I am pretty sure I am doing something dreadfully wrong, but can’t figure it out.

I created a simple wrapper around a class and added a dependency property so I could bind to it. However, the binding gives no errors, but does nothing.

In order to simplify things I changed the class to TextBox, and got the same results.

public class TextEditor : TextBox
{
    #region Public Properties

    #region EditorText
    /// <summary>
    /// Gets or sets the text of the editor
    /// </summary>
    public string EditorText
    {
      get
      {
        return (string)GetValue(EditorTextProperty);
      }

      set
      {
        //if (ValidateEditorText(value) == false) return;
        if (EditorText != value)
        {
          SetValue(EditorTextProperty, value);
          base.Text = value;

          //if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("EditorText"));
        }
      }
    }

    public static readonly DependencyProperty EditorTextProperty =
        DependencyProperty.Register("EditorText", typeof(string), typeof(TextEditor));
    #endregion

    #endregion

    #region Constructors

    public TextEditor()
    {
      //Attach to the text changed event
      //TextChanged += new EventHandler(TextEditor_TextChanged);
    }

    #endregion

    #region Event Handlers

    private void TextEditor_TextChanged(object sender, EventArgs e)
    {
      EditorText = base.Text;
    }

    #endregion
}

When I run the following XAML the first gives results, but the second one (EditorText) doesn’t even hit the EditorText property.

<local:TextEditor IsReadOnly="True" Text="{Binding Path=RuleValue, Mode=TwoWay}" WordWrap="True" />
<local:TextEditor IsReadOnly="True" EditorText="{Binding Path=RuleValue, Mode=TwoWay}" WordWrap="True" />
  • 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-18T04:19:02+00:00Added an answer on May 18, 2026 at 4:19 am

    You’re doing extra work in your CLR property. There is no guarantee that your CLR property will be used by WPF so you shouldn’t be doing this. Instead, use metadata on your DP to achieve the same effect.

    public string EditorText
    {
      get { return (string)GetValue(EditorTextProperty); }
      set { SetValue(EditorTextProperty, value); }
    }
    
    public static readonly DependencyProperty EditorTextProperty =
        DependencyProperty.Register(
            "EditorText",
            typeof(string),
            typeof(TextEditor),
            new FrameworkPropertyMetadata(OnEditorTextChanged));
    
    private static void OnEditorTextChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e)
    {
        var textEditor = dependencyObject as TextEditor;
    
        // do your extraneous work here
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am pretty sure I have seen this before, but I haven't found out
I'm pretty sure stackoverflow.com is created with ASP.NET, but no matter where I click
I'm pretty sure this is a simple question in regards to formatting but here's
I'm pretty sure there should be a more Pythonic way of doing this -
Pretty sure this question counts as blasphemy to most web 2.0 proponents, but I
I'm pretty sure I know the answer to this, but short of a virtual
intro: I am pretty sure this is my fault. But I just don't see
I'm pretty sure the answer is no but I thought I'd check. Background: I
So I'm pretty sure i already know the answer to this, but does the
I'm pretty sure most of us are familiar with the concept of a project's

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.