我正在尝试创建一个用户控件,该控件具有将其内容绑定到依赖对象的内容控件。代码如下
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));
我遇到的问题是,当我尝试使用 xaml 将内容定义为文本块,然后将文本属性绑定到我的应用程序中的字符串时,当字符串更改时它无法更新:
我的应用程序代码如下
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");
            }
        }
    }
任何关于我可能遗漏或可能做错的建议将不胜感激。
谢谢
[编辑]
此后,我将 Content 依赖属性更改为 NotifyContent,因为我收到警告说它正在将 Content 覆盖为 UserControl 但这仍然没有解决问题