I have to create a Binding to read the value of a property of an object that is the value of an attached property.
In XAML I can it this way:
<TextBlock Text="{Binding Path=(myns:MyDependencyObject.MyAttachedProperty).NestedProperty, Mode=OneWay}"/>
How can I do that in C# code?
You can do that via this approach:
The constructor used for PropertyPath is the following:
Please note that
"(0)"is similar to thestring.Formatsyntax, where(0)corresponds to the first parameter in thepathParametersparams list.The Microsoft's docs are not so clear about that.
See also: https://stackoverflow.com/a/12854657/1136211