Im new to WPF / Silverlight so its hard for me to describe what i try to do. Maybe that is the reason i could not find a answer on Stackoverflow and Google.
I try to bind to a DependyProperty programmatically.
public static DependencyProperty MyDependencyProperty
= DependencyProperty.RegisterAttached(
"...",
typeof(...),
typeof(...),
new PropertyMetadata(...)
);
xmlns:MyXMLNS="clr-namespace:...."
<ListBox MyXMLNS:MyClass.MyDependencyProperty="...">
// ....
</ListBox>
This already works as expected.
How can i get this done programmatically?
The format in code is always the same and just a non-verbatim translation if you know how the XAML is handled.
If you set other properties on the binding like ElementName you should set those before
SetBinding. (ThisSetBindingmethod is just for convenience (if you only set theBinding.Paththere even is another one), for non-FrameworkElements you needBindingOperations.SetBinding)