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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T09:37:55+00:00 2026-06-04T09:37:55+00:00

in my Silverlight 4 app, I try to create a simple UserControl, which will

  • 0

in my Silverlight 4 app, I try to create a simple UserControl, which will be consumed by my Application. To keep things simple, it shall have a “header” and a placeholder, where I want to place any kind of control.

<User Control ...>
  <Grid x:Name="LayoutRoot">
    <TextBlock x:Name="TextBlockHeader" Text="{Binding Title}" />
    <ContentPresenter x:Name="ContentPresenterObject" />
  </Grid>
</UserControl>

In the code behind, I have created a property for the text of the TextBlock

public string Title
{
  get { return (string)GetValue(TitleProperty); }
  set { SetValue(TitleProperty, value); }
}

public static readonly DependencyProperty TitleProperty = DependencyProperty.Register("Title", typeof(string), typeof(MyAccordion), null);

This way, I can set the Title property, when I use the Control in my application.

<local:MyAccordion Title="Test"/>

But it seems, that the binding at the textblock Text=”{Binding Title}” doesn’t make the text “Test” to be displayed as the textblocks text.

My question is: How can I make the Property Title to be displayed as the textboxes text and how do I do this for the – any type of user control containable – contencontrol?

Thanks in advance,
Frank

  • 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-04T09:37:57+00:00Added an answer on June 4, 2026 at 9:37 am

    The answer is ElementPropertyBinding. I need to reference the User Control in the Binding or add the binding in the constructor.

    Create the binding in XAML:

    <User Control ... x:Name="userControl">
      ...
      <TextBlock x:Name="TextBlockHeader" Text="{Binding Title, ElementName=userControl}" />
    </UserControl>
    

    Create the binding in the constructor (Code behind)

    public MyUserControl()
    {
      // Required to initialize variables
      InitializeComponent();
    
      TextBlockHeader.SetBinding(TextBlock.TextProperty, new System.Windows.Data.Binding() { Source = this, Path = new PropertyPath("Title") });
    }
    

    I still need to find out how to add a child control, but that’s another question.

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

Sidebar

Related Questions

I am doing small Silverlight app which will allow users to Create orders. I
Let me try to explain my challenge. I'm building a Silverlight app which will
I have a small Silverlight app which downloads all of the images and text
I have a silverlight app that will be installed OOB with full trust and
I have a simple Silverlight app that I want to run on Windows Phone
I have an Image element in my WP7.5 Silverlight app for which I tried
I have a Silverlight web app using WCF and Membership.CreateUser to create new users.
I am developing a Silverlight app using VS2008 Express. I have just implemented a
I have a Silverlight app with a DataGrid containing some custom columns and all
I created a silverlight app (without website) named TestApp , with one TextBox: <UserControl

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.