By default binding engine will search for property in its DataContext, but since you haven't provided any DataContext to your UserControl and Window, binding is failing silently which you can see in output window of Visual Studio.
You can use RelativeSource markup extension to resolve the binding.
UserControl:
<TextBox Text="{Binding Path,RelativeSource={RelativeSource Mode=FindAncestor,
AncestorType=UserControl}}"
Width="250"/>
Window
<local:SampleUserControl Path="{Binding FilePath, Mode=TwoWay,
RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}"/>
Also you have to set Mode
to TwoWay
so that any change gets propagated from source to target and vice versa. Default value for custom DP is OneWay.
Othwerwise, you can specify it in your custom DP Path
to bind TwoWay by default by setting FrameworkPropertyMetadataOptions.BindsTwoWayByDefault
on Path DP. This way you don't have to explicitly set binding mode on your XAML bindings.
public static readonly DependencyProperty PathProperty =
DependencyProperty.Register("Path", typeof(string), typeof(UserControl1),
new FrameworkPropertyMetadata(string.Empty,
FrameworkPropertyMetadataOptions.BindsTwoWayByDefault));