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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:51:39+00:00 2026-05-23T15:51:39+00:00

I’ve created a UserControl with an ItemContext DependencyProperty . This property contains the name

  • 0

I’ve created a UserControl with an ItemContext DependencyProperty. This property contains the name of the property of my DataContext object the Control’s text property should bind to.

I cannot figure out how to do this in XAML. I tried several steps, I’m quite near but couldn’t find it.

Something like this:

<TextBox Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type me:UserControl}}, Path=ItemContext}" />

But here the contents of “ItemContext” is bound directly to the Text Property which I don’t want. The contents of “ItemContext” let’s say “Property1” is the name of the property in my DataContext I’d like to bind to.

In code it works like this:

this.txtValue0.SetBinding(TextBox.TextProperty, new Binding(this.ItemContext) { Mode = BindingMode.TwoWay });

Does someone have an idea?

Thanks

  • 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-23T15:51:40+00:00Added an answer on May 23, 2026 at 3:51 pm

    It sounds as though what you’re trying to pass an external value into the Path property of a Binding object. That is, if ItemContext‘s value is “Blob”, you want to bind to DataContext.Blob (not display the value “Blob”).

    That’s easy to do in code, because you can reference the value directly (you pass this.ItemContext to your binding as a one-time value). In markup, however, you can’t do this. Instead, you’re trying to bind a value to the Path of the Binding, but you can’t (because it’s not a DependencyProperty).

    I’d suggest that a much easier solution would be to create a different property on your UserControl: instead of passing in “the name of the thing you want to bind to,” why not just pass in the value of the thing?

    I’m imagining that your current code looks like this:

    <u:MyControl DataContext="{Binding SomeObject}" ItemContext="MyPropertyName" />
    

    … and instead you should make it look like this:

    <u:MyControl DataContext="{Binding SomeObject}" ItemValue="{Binding MyPropertyName}" />
    

    … so the value is resolved externally of the control. Within the control, you can use @dowhilefor’s solution to bind to the value.

    Hope that makes sense!

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

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I have a text area in my form which accepts all possible characters from
Does anyone know how can I replace this 2 symbol below from the string

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.