in Education by
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: 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 JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
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: ... and instead you should make it look like this: ... 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!

Related questions

0 votes
    I've created a UserControl with an ItemContext DependencyProperty. This property contains the name of the property ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 2, 2022 in Education by JackTerrance
0 votes
    I've created a UserControl with an ItemContext DependencyProperty. This property contains the name of the property ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 2, 2022 in Education by JackTerrance
0 votes
    What is string interpolation and property binding in Angular?...
asked Jun 30, 2021 in Technology by JackTerrance
0 votes
    Which of the following key property holds the key name as a string? (a) keyName (b) key (c) ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 22, 2021 in Education by JackTerrance
0 votes
    Which of the following is the correct form control class name that is set to true via [(ngModel)] whenever value is changed? ... 2. .ng-dirty 3. .ng-pending 4. .ng-invalid...
asked Jun 29, 2021 in Technology by JackTerrance
0 votes
    Name the compound which shows anti-ferroelectric property. Select the correct answer from above options...
asked Jan 5, 2022 in Education by JackTerrance
0 votes
    Which is the property of a Window object that holds the name of the frame? (a) name (b) title ( ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 22, 2021 in Education by JackTerrance
0 votes
    I think the direct answer to the question is 'No' but I'm hoping that someone has written a real ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 11, 2022 in Education by JackTerrance
0 votes
    Which of the following property specifies the string of text that was entered? (a) message (b) data ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 23, 2021 in Education by JackTerrance
0 votes
    I want to include a batch file rename functionality in my application. A user can type a destination ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 29, 2022 in Education by JackTerrance
0 votes
    Using the WCF web programming model one can specify an operation contract like so: [OperationContract] [WebGet ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 11, 2022 in Education by JackTerrance
0 votes
    I am getting Facebook users' friends birthday back from Facebook in the following format: 10/07/1967 or ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 21, 2022 in Education by JackTerrance
0 votes
    I am getting Facebook users' friends birthday back from Facebook in the following format: 10/07/1967 or ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 21, 2022 in Education by JackTerrance
0 votes
    Write a function to extract the first name in the string Mrs. Jake Luther ? (a) Substring (b) Substr ( ... Debugging of R Programming Select the correct answer from above options...
asked Feb 13, 2022 in Education by JackTerrance
...