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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:41:25+00:00 2026-06-09T12:41:25+00:00

I am trying to create a user control that has a contentcontrol which binds

  • 0

I am trying to create a user control that has a contentcontrol which binds its content tio a dependancy object. The code is as follows

Xaml

    <ContentControl Grid.Column="1" HorizontalAlignment="Stretch" x:Name="NotifyContent" Content="{Binding ElementName=notifyBarCtrl, Path=Content, NotifyOnSourceUpdated=True}" />

c#

public object Content
{
    get { return (object)GetValue(ContentProperty); }
    set { SetValue(ContentProperty, value); }
}

// Using a DependencyProperty as the backing store for Content.  This enables animation, styling, binding, etc...
public static readonly DependencyProperty ContentProperty =
    DependencyProperty.Register("Content", typeof(object), typeof(NotifyBar));

The problem I’m having is that when I try to define the content as a textblock using xaml and then bind the text property to a string in my application it fails to update when the string changes:

My application code is as follows

Xaml

<ctrl:NotifyBar DockPanel.Dock="Top" Background="White" HorizontalAlignment="Stretch" >
    <ctrl:NotifyBar.Content>
        <TextBlock Height="30" Text="{Binding ElementName=MainWindow, Path=NotifyMessage, Mode=TwoWay}" HorizontalAlignment="Stretch" />
    </ctrl:NotifyBar.Content>
</ctrl:NotifyBar>

c#

    public string NotifyMessage
    {
        get { return _NotifyMessage; }
        set 
        {
            if (_NotifyMessage != value)
            {
                _NotifyMessage = value;
                OnPropertyChanged("NotifyMessage");
            }
        }
    }

any suggestions as to what I might be missing or might have done wrong would be much appreciated.

Thanks

[Edit]

I have since changed the Content dependancy property to NotifyContent as I was getting a warning that it was overriding the Content to UserControl but this still hasnt resolved the issue

  • 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-09T12:41:27+00:00Added an answer on June 9, 2026 at 12:41 pm

    So I figured out that it was because I was using elementname within the the textblock.

    If I set the DataContext of the usercontrol to the element and bind to the propertiesit works.

    see below:

    <ctrl:NotifyBar DataContext="{Binding ElementName=MainWindow}"  DockPanel.Dock="Top" Background="White" HorizontalAlignment="Stretch" >
        <ctrl:NotifyBar.Content>
            <TextBlock Height="30" Text="{Binding Path=NotifyMessage, Mode=TwoWay}" HorizontalAlignment="Stretch" />
        </ctrl:NotifyBar.Content>
    </ctrl:NotifyBar>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a user control that has a Grid with two rows.
i'm trying to learn about user controls. I created a user control that has
I'm trying to create User Control which will work like a rich button. It's
I am trying to create a simple User Control (not WPF) in VS2008 which
Im trying to create a user control menu where links to a page's usercontrols
I'm trying to create a user control in WPF to represent a Go board
I have a user control that has a grid (the one you get automatically
I have a partial view (user control) that is shared by my Create and
I'm trying to create a plugin for nopCommerce v2.20 that allows the user to
So I've got a control that has all different user inputs (comboBox, textBox, DatePicker,

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.