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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:53:54+00:00 2026-05-23T07:53:54+00:00

In my code I have declared, within the custom control ValidatingTextBox, the following dependency

  • 0

In my code I have declared, within the custom control ValidatingTextBox, the following dependency property:

public DependencyProperty visibleText = DependencyProperty.RegisterAttached("visText", typeof(String), typeof(ValidatingTextBox));
public String visText
{
    get { return theBox.Text; }
    set { theBox.Text = value; }
}

But when I try to use the xaml

<local:ValidatingTextBox>
    <ValidatingTextBox.visibleText>

    </ValidatingTextBox.visibleText>
</local:ValidatingTextBox>

it says that such a dependencyproperty doesn’t exist within ValidatingTextBox. What am I doing wrong? Is there a better way to interact with the child text box of my custom control?

  • 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-23T07:53:55+00:00Added an answer on May 23, 2026 at 7:53 am

    In the register method you registered it as visText, the name of the field does not have anything to do with the property itself. You also seem to define an attached property which is going to be used like a normal property, you should define it as a normal dependency-property.

    Further you create two properties, a depedency property without a CLR-wrapper and a normal property by doing this:

    public String visText
    {
        get { return theBox.Text; }
        set { theBox.Text = value; }
    }
    

    It has nothing to do with the value of your actual depedency property since it never accesses it. Besides that the property field should be static and readonly.

    Reading through the Depedency Properties Overview is advised as this is quite a mess, also have a look at the article on creating custom dependency properties which should be quite helpful.


    To address your question of how to interact with the child controls: Create (proper) dependency properties and bind to them.

    Since the property already exists on the child you can also reuse it with AddOwner:

    public static readonly DependencyProperty TextProperty =
        TextBox.TextProperty.AddOwner(typeof(MyControl));
    public string Text
    {
        get { return (string)GetValue(TextProperty); }
        set { SetValue(TextProperty, value); }
    }
    
    <!-- Assuming a usercontrol rather than a custom control -->
    <!-- If you have a custom control and the child controls are created in code you can do the binding there -->
    <UserControl ...
          Name="control">
        <!-- ... -->
        <TextBox Text="{Binding Text, ElementName=control}"/>
        <!-- ... -->
    </UserControl>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my C# source code I may have declared integers as: int i =
I have declared an enum in my server code, and would like my client
I have the OnSendingMail event declared in the CreateUserWizard markup. I have the code
i have following code #include <iostream> #include <set> #include <string> using namespace std; template<class
I have the following code for example $(a.foo).bind(function (e){ var t; if ( $(e.target).is(a)
I want to know all the variables that have been declared within an include
Suppose we have declared these two classes: public class Animal { //..... } public
Good Morning, I have the following line of code: var viewModel = new ClassifiedsBrowseViewModel
I have a Custom control in WPF in which I define a large ItemsControl
I have the following code where class A declares class B as friend. Should

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.