I have problem with binding to dependency property of my new control.
I decided to write some tests to examine this issue.
Binding from TextBox.Text to another TextBox.Text
XAML code:
<TextBox Name="Test" Text="{Binding ElementName=Test2, Path=Text, UpdateSourceTrigger=PropertyChanged}" />
<TextBox Name="Test2" Grid.Row="2" />
The result is good – when I writing something in first TextBox -> second TextBox is updating (conversely too).

I created new control -> for example “SuperTextBox” with dependency property “SuperValue”.
Control XAML code:
<UserControl x:Class="WpfApplication2.SuperTextBox"
...
Name="Root">
<TextBox Text="{Binding SuperValue, ElementName=Root, UpdateSourceTrigger=PropertyChanged}" />
</UserControl>
Code behind:
public partial class SuperTextBox : UserControl
{
public SuperTextBox()
{
InitializeComponent();
}
public static readonly DependencyProperty SuperValueProperty = DependencyProperty.Register(
"SuperValue",
typeof(string),
typeof(SuperTextBox),
new FrameworkPropertyMetadata(string.Empty)
);
public string SuperValue
{
get { return (string)GetValue(SuperValueProperty); }
set { SetValue(SuperValueProperty, value); }
}
}
Ok, and now tests!
Binding from TextBox.Text to SuperTextBox.SuperValue
<TextBox x:Name="Test1" Text="{Binding ElementName=Test2, Path=SuperValue, UpdateSourceTrigger=PropertyChanged}" />
<local:SuperTextBox x:Name="Test2" Grid.Row="2"/>
Test is correct too!
When I writing something in TextBox, SuperTextBox is updating.
When i writing in SuperTextBox, TextBox is updating.
All is ok!
Now a problem:
Binding from SuperTextBox.SuperValue to TextBox.Text
<TextBox x:Name="Test1"/>
<local:SuperTextBox x:Name="Test2" SuperValue="{Binding ElementName=Test1, Path=Text, UpdateSourceTrigger=PropertyChanged}" Grid.Row="2"/>
In this case, when I writing something in SuperTextBox, TextBox is not updating!

How can I fix this?
PS: Question is very very long, I am sorry for that, but i tried exactly describe my problem.
The reason why one works and the other doesn’t is because the
Textdependency property ofTextBoxis defined to bindTwoWayby default, while your dependency propertySuperValueisn’t. You need to use TwoWay-binding if you want the destination to update the source in addition to the source updating the destination.To fix this, you can add
FrameworkPropertyMetadataOptions.BindsTwoWayByDefaulttoSuperValue'smetadata like so: