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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:30:37+00:00 2026-06-14T07:30:37+00:00

I have the following MyAwesomeControl (user control) It has a text box inside it.

  • 0

I have the following

MyAwesomeControl (user control)

It has a text box inside it. which is bound to a dependency property called Text.

SimpleViewModel

like object (not really a VM, but it gets the point across), sets up a collection of people (which is observable)

it also has a SelectedPerson property, which notifies on change

Main page control

Has its data context set to the SimpleViewModel
contains a grid which is bound to the collection of people (this is used to select a person)

MyAwesomeControl with its Text property bound to SelectedPerson.Name

A TextBlock also bound to the SelectedPerson.Name

I made a small solution here : https://skydrive.live.com/redir?resid=82ECBE29B8DC2CD5!300

The issue

when i select a person in the grid the text box in MyAwesomeControl does not update.

the text block on the main form does.

how can we allow the user to supply the binding to the Text of the MyAwesomeControl, and have that update the internal text box (note this control is to be reused, so i cannot be aware of main page specific values)

many 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-06-14T07:30:39+00:00Added an answer on June 14, 2026 at 7:30 am

    When you need to bind to a custom dependecy property inside a custom usercontrol you need to use element binding, and don’t set the DataContext inside your user control.

    So you need to follow these steps to make your sample work:

    • You need to remove the DataContext = this; from your userControl’s constructor

    • Just add a name to your UserControl e.g. <UserControl ... x:Name="Self" >

    • And use ElementName with Self in your text binding (inside MyAwsomeControl.xaml):

      Text="{Binding Text, ElementName=Self, Mode=TwoWay}"
      

    If you wan’t to make the update work you also need to set Mode to TwoWay where you use your custom control (inside MainPage.xaml):

    Text="{Binding SelectedPerson.Name, Mode=TwoWay}"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have following div in a page (I can not modify). <div id=:0.control>Click me</div>
I have following json data which I want to pass it to server using
I have following code, which executes on button press. At first it works as
I have following relation. A company has several employees. Each employee is defined by
I have following simple HTML and JS code. When User selects Italian Language option
I have following class which reads and writes an array of objects from/to a
I have following setup. from django.db import models from django.contrib.auth.models import User class Event(models.Model):
I have following asp hyperlink: <asp:HyperLink ID=a runat=server Text=return NavigateUrl=https://google.com/></asp:HyperLink > What i want
I have following data in text file 375020222511963 284970411563422 290245594366931 I need to retrieve
Have following validation for year value from text input: if (!year.match(new RegExp('\\d{4}'))){ ... }

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.